@atlaskit/editor-plugin-text-formatting 0.1.1 → 0.2.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.
@@ -6,16 +6,15 @@ import { jsx } from '@emotion/react';
6
6
  import { INPUT_METHOD, TOOLBAR_ACTION_SUBJECT_ID } from '@atlaskit/editor-common/analytics';
7
7
  import { getAriaKeyshortcuts, toggleBold, toggleCode, toggleItalic, toggleStrikethrough, toggleSubscript, toggleSuperscript, toggleUnderline, tooltip, ToolTipContent } from '@atlaskit/editor-common/keymaps';
8
8
  import { toolbarMessages } from '@atlaskit/editor-common/messages';
9
+ import { pluginCommandToPMCommand } from '@atlaskit/editor-common/preset';
9
10
  import { shortcutStyle } from '@atlaskit/editor-shared-styles/shortcut';
10
11
  import BoldIcon from '@atlaskit/icon/glyph/editor/bold';
11
12
  import ItalicIcon from '@atlaskit/icon/glyph/editor/italic';
12
- import { toggleCodeWithAnalytics, toggleEmWithAnalytics, toggleStrikeWithAnalytics, toggleStrongWithAnalytics, toggleSubscriptWithAnalytics, toggleSuperscriptWithAnalytics, toggleUnderlineWithAnalytics } from '../../../actions';
13
+ import { toggleCodeWithAnalytics, toggleEmWithAnalytics, toggleStrikeWithAnalytics, toggleStrongWithAnalytics, toggleSubscriptWithAnalytics, toggleSuperscriptWithAnalytics, toggleUnderlineWithAnalytics } from '../../../commands';
13
14
  import { pluginKey as textFormattingPluginKey } from '../../../pm-plugins/plugin-key';
14
15
  import { IconTypes } from '../types';
15
16
  var withToolbarInputMethod = function withToolbarInputMethod(func) {
16
- return func({
17
- inputMethod: INPUT_METHOD.TOOLBAR
18
- });
17
+ return pluginCommandToPMCommand(func(INPUT_METHOD.TOOLBAR));
19
18
  };
20
19
  var IconButtons = function IconButtons(editorAnalyticsAPI) {
21
20
  return {
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-text-formatting",
3
- "version": "0.1.1",
3
+ "version": "0.2.0",
4
4
  "sideEffects": false
5
5
  }
@@ -0,0 +1,19 @@
1
+ import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
2
+ import type { InputMethodBasic, PluginCommand } from '@atlaskit/editor-common/types';
3
+ type ToggleMarkWithAnalyticsPluginCommand = (editorAnalyticsApi: EditorAnalyticsAPI | undefined) => ToggleMarkPluginCommand;
4
+ export type ToggleMarkPluginCommand = (inputMethod: InputMethodBasic) => PluginCommand;
5
+ export declare const toggleEm: PluginCommand;
6
+ export declare const toggleEmWithAnalytics: ToggleMarkWithAnalyticsPluginCommand;
7
+ export declare const toggleStrike: PluginCommand;
8
+ export declare const toggleStrikeWithAnalytics: ToggleMarkWithAnalyticsPluginCommand;
9
+ export declare const toggleStrong: PluginCommand;
10
+ export declare const toggleStrongWithAnalytics: ToggleMarkWithAnalyticsPluginCommand;
11
+ export declare const toggleUnderline: PluginCommand;
12
+ export declare const toggleUnderlineWithAnalytics: ToggleMarkWithAnalyticsPluginCommand;
13
+ export declare const toggleSuperscript: PluginCommand;
14
+ export declare const toggleSuperscriptWithAnalytics: ToggleMarkWithAnalyticsPluginCommand;
15
+ export declare const toggleSubscript: PluginCommand;
16
+ export declare const toggleSubscriptWithAnalytics: ToggleMarkWithAnalyticsPluginCommand;
17
+ export declare const toggleCode: PluginCommand;
18
+ export declare const toggleCodeWithAnalytics: ToggleMarkWithAnalyticsPluginCommand;
19
+ export {};
@@ -1,3 +1,3 @@
1
1
  export { textFormattingPlugin } from './plugin';
2
2
  export type { TextFormattingPlugin } from './plugin';
3
- export type { ToggleMarkWithAnalyticsCommand } from './actions';
3
+ export type { ToggleMarkPluginCommand } from './commands';
@@ -1,17 +1,17 @@
1
1
  import type { NextEditorPlugin, OptionalPlugin, TextFormattingOptions } from '@atlaskit/editor-common/types';
2
2
  import type { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
3
- import type { ToggleMarkWithAnalyticsCommand } from './actions';
3
+ import type { ToggleMarkPluginCommand } from './commands';
4
4
  export type TextFormattingPlugin = NextEditorPlugin<'textFormatting', {
5
5
  pluginConfiguration: TextFormattingOptions | undefined;
6
6
  dependencies: [OptionalPlugin<typeof analyticsPlugin>];
7
- actions: {
8
- toggleSuperscript: ToggleMarkWithAnalyticsCommand;
9
- toggleSubscript: ToggleMarkWithAnalyticsCommand;
10
- toggleStrike: ToggleMarkWithAnalyticsCommand;
11
- toggleCode: ToggleMarkWithAnalyticsCommand;
12
- toggleUnderline: ToggleMarkWithAnalyticsCommand;
13
- toggleEm: ToggleMarkWithAnalyticsCommand;
14
- toggleStrong: ToggleMarkWithAnalyticsCommand;
7
+ commands: {
8
+ toggleSuperscript: ToggleMarkPluginCommand;
9
+ toggleSubscript: ToggleMarkPluginCommand;
10
+ toggleStrike: ToggleMarkPluginCommand;
11
+ toggleCode: ToggleMarkPluginCommand;
12
+ toggleUnderline: ToggleMarkPluginCommand;
13
+ toggleEm: ToggleMarkPluginCommand;
14
+ toggleStrong: ToggleMarkPluginCommand;
15
15
  };
16
16
  }>;
17
17
  export declare const textFormattingPlugin: TextFormattingPlugin;
@@ -0,0 +1,19 @@
1
+ import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
2
+ import type { InputMethodBasic, PluginCommand } from '@atlaskit/editor-common/types';
3
+ type ToggleMarkWithAnalyticsPluginCommand = (editorAnalyticsApi: EditorAnalyticsAPI | undefined) => ToggleMarkPluginCommand;
4
+ export type ToggleMarkPluginCommand = (inputMethod: InputMethodBasic) => PluginCommand;
5
+ export declare const toggleEm: PluginCommand;
6
+ export declare const toggleEmWithAnalytics: ToggleMarkWithAnalyticsPluginCommand;
7
+ export declare const toggleStrike: PluginCommand;
8
+ export declare const toggleStrikeWithAnalytics: ToggleMarkWithAnalyticsPluginCommand;
9
+ export declare const toggleStrong: PluginCommand;
10
+ export declare const toggleStrongWithAnalytics: ToggleMarkWithAnalyticsPluginCommand;
11
+ export declare const toggleUnderline: PluginCommand;
12
+ export declare const toggleUnderlineWithAnalytics: ToggleMarkWithAnalyticsPluginCommand;
13
+ export declare const toggleSuperscript: PluginCommand;
14
+ export declare const toggleSuperscriptWithAnalytics: ToggleMarkWithAnalyticsPluginCommand;
15
+ export declare const toggleSubscript: PluginCommand;
16
+ export declare const toggleSubscriptWithAnalytics: ToggleMarkWithAnalyticsPluginCommand;
17
+ export declare const toggleCode: PluginCommand;
18
+ export declare const toggleCodeWithAnalytics: ToggleMarkWithAnalyticsPluginCommand;
19
+ export {};
@@ -1,3 +1,3 @@
1
1
  export { textFormattingPlugin } from './plugin';
2
2
  export type { TextFormattingPlugin } from './plugin';
3
- export type { ToggleMarkWithAnalyticsCommand } from './actions';
3
+ export type { ToggleMarkPluginCommand } from './commands';
@@ -1,19 +1,19 @@
1
1
  import type { NextEditorPlugin, OptionalPlugin, TextFormattingOptions } from '@atlaskit/editor-common/types';
2
2
  import type { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
3
- import type { ToggleMarkWithAnalyticsCommand } from './actions';
3
+ import type { ToggleMarkPluginCommand } from './commands';
4
4
  export type TextFormattingPlugin = NextEditorPlugin<'textFormatting', {
5
5
  pluginConfiguration: TextFormattingOptions | undefined;
6
6
  dependencies: [
7
7
  OptionalPlugin<typeof analyticsPlugin>
8
8
  ];
9
- actions: {
10
- toggleSuperscript: ToggleMarkWithAnalyticsCommand;
11
- toggleSubscript: ToggleMarkWithAnalyticsCommand;
12
- toggleStrike: ToggleMarkWithAnalyticsCommand;
13
- toggleCode: ToggleMarkWithAnalyticsCommand;
14
- toggleUnderline: ToggleMarkWithAnalyticsCommand;
15
- toggleEm: ToggleMarkWithAnalyticsCommand;
16
- toggleStrong: ToggleMarkWithAnalyticsCommand;
9
+ commands: {
10
+ toggleSuperscript: ToggleMarkPluginCommand;
11
+ toggleSubscript: ToggleMarkPluginCommand;
12
+ toggleStrike: ToggleMarkPluginCommand;
13
+ toggleCode: ToggleMarkPluginCommand;
14
+ toggleUnderline: ToggleMarkPluginCommand;
15
+ toggleEm: ToggleMarkPluginCommand;
16
+ toggleStrong: ToggleMarkPluginCommand;
17
17
  };
18
18
  }>;
19
19
  export declare const textFormattingPlugin: TextFormattingPlugin;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-text-formatting",
3
- "version": "0.1.1",
3
+ "version": "0.2.0",
4
4
  "description": "Text-formatting plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -32,7 +32,7 @@
32
32
  },
33
33
  "dependencies": {
34
34
  "@atlaskit/adf-schema": "^28.0.0",
35
- "@atlaskit/editor-common": "^74.44.0",
35
+ "@atlaskit/editor-common": "^74.45.0",
36
36
  "@atlaskit/editor-plugin-analytics": "^0.1.0",
37
37
  "@atlaskit/editor-prosemirror": "1.1.0",
38
38
  "@atlaskit/editor-shared-styles": "^2.5.0",
package/report.api.md CHANGED
@@ -16,10 +16,10 @@
16
16
 
17
17
  ```ts
18
18
  import type { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
19
- import type { Command } from '@atlaskit/editor-common/types';
20
19
  import type { InputMethodBasic } from '@atlaskit/editor-common/types';
21
20
  import type { NextEditorPlugin } from '@atlaskit/editor-common/types';
22
21
  import type { OptionalPlugin } from '@atlaskit/editor-common/types';
22
+ import type { PluginCommand } from '@atlaskit/editor-common/types';
23
23
  import type { TextFormattingOptions } from '@atlaskit/editor-common/types';
24
24
 
25
25
  // @public (undocumented)
@@ -28,14 +28,14 @@ export type TextFormattingPlugin = NextEditorPlugin<
28
28
  {
29
29
  pluginConfiguration: TextFormattingOptions | undefined;
30
30
  dependencies: [OptionalPlugin<typeof analyticsPlugin>];
31
- actions: {
32
- toggleSuperscript: ToggleMarkWithAnalyticsCommand;
33
- toggleSubscript: ToggleMarkWithAnalyticsCommand;
34
- toggleStrike: ToggleMarkWithAnalyticsCommand;
35
- toggleCode: ToggleMarkWithAnalyticsCommand;
36
- toggleUnderline: ToggleMarkWithAnalyticsCommand;
37
- toggleEm: ToggleMarkWithAnalyticsCommand;
38
- toggleStrong: ToggleMarkWithAnalyticsCommand;
31
+ commands: {
32
+ toggleSuperscript: ToggleMarkPluginCommand;
33
+ toggleSubscript: ToggleMarkPluginCommand;
34
+ toggleStrike: ToggleMarkPluginCommand;
35
+ toggleCode: ToggleMarkPluginCommand;
36
+ toggleUnderline: ToggleMarkPluginCommand;
37
+ toggleEm: ToggleMarkPluginCommand;
38
+ toggleStrong: ToggleMarkPluginCommand;
39
39
  };
40
40
  }
41
41
  >;
@@ -44,9 +44,9 @@ export type TextFormattingPlugin = NextEditorPlugin<
44
44
  export const textFormattingPlugin: TextFormattingPlugin;
45
45
 
46
46
  // @public (undocumented)
47
- export type ToggleMarkWithAnalyticsCommand = (analyticsMetadata: {
48
- inputMethod: InputMethodBasic;
49
- }) => Command;
47
+ export type ToggleMarkPluginCommand = (
48
+ inputMethod: InputMethodBasic,
49
+ ) => PluginCommand;
50
50
 
51
51
  // (No @packageDocumentation comment for this package)
52
52
  ```
@@ -5,24 +5,24 @@
5
5
  ```ts
6
6
 
7
7
  import type { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
8
- import type { Command } from '@atlaskit/editor-common/types';
9
8
  import type { InputMethodBasic } from '@atlaskit/editor-common/types';
10
9
  import type { NextEditorPlugin } from '@atlaskit/editor-common/types';
11
10
  import type { OptionalPlugin } from '@atlaskit/editor-common/types';
11
+ import type { PluginCommand } from '@atlaskit/editor-common/types';
12
12
  import type { TextFormattingOptions } from '@atlaskit/editor-common/types';
13
13
 
14
14
  // @public (undocumented)
15
15
  export type TextFormattingPlugin = NextEditorPlugin<'textFormatting', {
16
16
  pluginConfiguration: TextFormattingOptions | undefined;
17
17
  dependencies: [OptionalPlugin<typeof analyticsPlugin>];
18
- actions: {
19
- toggleSuperscript: ToggleMarkWithAnalyticsCommand;
20
- toggleSubscript: ToggleMarkWithAnalyticsCommand;
21
- toggleStrike: ToggleMarkWithAnalyticsCommand;
22
- toggleCode: ToggleMarkWithAnalyticsCommand;
23
- toggleUnderline: ToggleMarkWithAnalyticsCommand;
24
- toggleEm: ToggleMarkWithAnalyticsCommand;
25
- toggleStrong: ToggleMarkWithAnalyticsCommand;
18
+ commands: {
19
+ toggleSuperscript: ToggleMarkPluginCommand;
20
+ toggleSubscript: ToggleMarkPluginCommand;
21
+ toggleStrike: ToggleMarkPluginCommand;
22
+ toggleCode: ToggleMarkPluginCommand;
23
+ toggleUnderline: ToggleMarkPluginCommand;
24
+ toggleEm: ToggleMarkPluginCommand;
25
+ toggleStrong: ToggleMarkPluginCommand;
26
26
  };
27
27
  }>;
28
28
 
@@ -30,9 +30,7 @@ export type TextFormattingPlugin = NextEditorPlugin<'textFormatting', {
30
30
  export const textFormattingPlugin: TextFormattingPlugin;
31
31
 
32
32
  // @public (undocumented)
33
- export type ToggleMarkWithAnalyticsCommand = (analyticsMetadata: {
34
- inputMethod: InputMethodBasic;
35
- }) => Command;
33
+ export type ToggleMarkPluginCommand = (inputMethod: InputMethodBasic) => PluginCommand;
36
34
 
37
35
  // (No @packageDocumentation comment for this package)
38
36
 
@@ -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,161 +0,0 @@
1
- import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
2
- import { withAnalytics } from '@atlaskit/editor-common/editor-analytics';
3
- import { toggleMark } from '@atlaskit/editor-common/mark';
4
- export const toggleEm = () => {
5
- return (state, dispatch) => {
6
- const {
7
- em
8
- } = state.schema.marks;
9
- if (em) {
10
- return toggleMark(em)(state, dispatch);
11
- }
12
- return false;
13
- };
14
- };
15
- export const toggleEmWithAnalytics = editorAnalyticsAPI => ({
16
- inputMethod
17
- }) => withAnalytics(editorAnalyticsAPI, {
18
- action: ACTION.FORMATTED,
19
- actionSubject: ACTION_SUBJECT.TEXT,
20
- eventType: EVENT_TYPE.TRACK,
21
- actionSubjectId: ACTION_SUBJECT_ID.FORMAT_ITALIC,
22
- attributes: {
23
- inputMethod
24
- }
25
- })(toggleEm());
26
- export const toggleStrike = () => {
27
- return (state, dispatch) => {
28
- const {
29
- strike
30
- } = state.schema.marks;
31
- if (strike) {
32
- return toggleMark(strike)(state, dispatch);
33
- }
34
- return false;
35
- };
36
- };
37
- export const toggleStrikeWithAnalytics = editorAnalyticsAPI => ({
38
- inputMethod
39
- }) => withAnalytics(editorAnalyticsAPI, {
40
- action: ACTION.FORMATTED,
41
- actionSubject: ACTION_SUBJECT.TEXT,
42
- eventType: EVENT_TYPE.TRACK,
43
- actionSubjectId: ACTION_SUBJECT_ID.FORMAT_STRIKE,
44
- attributes: {
45
- inputMethod
46
- }
47
- })(toggleStrike());
48
- export const toggleStrong = () => {
49
- return (state, dispatch) => {
50
- const {
51
- strong
52
- } = state.schema.marks;
53
- if (strong) {
54
- return toggleMark(strong)(state, dispatch);
55
- }
56
- return false;
57
- };
58
- };
59
- export const toggleStrongWithAnalytics = editorAnalyticsAPI => ({
60
- inputMethod
61
- }) => withAnalytics(editorAnalyticsAPI, {
62
- action: ACTION.FORMATTED,
63
- actionSubject: ACTION_SUBJECT.TEXT,
64
- eventType: EVENT_TYPE.TRACK,
65
- actionSubjectId: ACTION_SUBJECT_ID.FORMAT_STRONG,
66
- attributes: {
67
- inputMethod
68
- }
69
- })(toggleStrong());
70
- export const toggleUnderline = () => {
71
- return (state, dispatch) => {
72
- const {
73
- underline
74
- } = state.schema.marks;
75
- if (underline) {
76
- return toggleMark(underline)(state, dispatch);
77
- }
78
- return false;
79
- };
80
- };
81
- export const toggleUnderlineWithAnalytics = editorAnalyticsAPI => ({
82
- inputMethod
83
- }) => withAnalytics(editorAnalyticsAPI, {
84
- action: ACTION.FORMATTED,
85
- actionSubject: ACTION_SUBJECT.TEXT,
86
- eventType: EVENT_TYPE.TRACK,
87
- actionSubjectId: ACTION_SUBJECT_ID.FORMAT_UNDERLINE,
88
- attributes: {
89
- inputMethod
90
- }
91
- })(toggleUnderline());
92
- export const toggleSuperscript = () => {
93
- return (state, dispatch) => {
94
- const {
95
- subsup
96
- } = state.schema.marks;
97
- if (subsup) {
98
- return toggleMark(subsup, {
99
- type: 'sup'
100
- })(state, dispatch);
101
- }
102
- return false;
103
- };
104
- };
105
- export const toggleSuperscriptWithAnalytics = editorAnalyticsAPI => ({
106
- inputMethod
107
- }) => withAnalytics(editorAnalyticsAPI, {
108
- action: ACTION.FORMATTED,
109
- actionSubject: ACTION_SUBJECT.TEXT,
110
- eventType: EVENT_TYPE.TRACK,
111
- actionSubjectId: ACTION_SUBJECT_ID.FORMAT_SUPER,
112
- attributes: {
113
- inputMethod
114
- }
115
- })(toggleSuperscript());
116
- export const toggleSubscript = () => {
117
- return (state, dispatch) => {
118
- const {
119
- subsup
120
- } = state.schema.marks;
121
- if (subsup) {
122
- return toggleMark(subsup, {
123
- type: 'sub'
124
- })(state, dispatch);
125
- }
126
- return false;
127
- };
128
- };
129
- export const toggleSubscriptWithAnalytics = editorAnalyticsAPI => ({
130
- inputMethod
131
- }) => withAnalytics(editorAnalyticsAPI, {
132
- action: ACTION.FORMATTED,
133
- actionSubject: ACTION_SUBJECT.TEXT,
134
- eventType: EVENT_TYPE.TRACK,
135
- actionSubjectId: ACTION_SUBJECT_ID.FORMAT_SUB,
136
- attributes: {
137
- inputMethod
138
- }
139
- })(toggleSubscript());
140
- export const toggleCode = () => {
141
- return (state, dispatch) => {
142
- const {
143
- code
144
- } = state.schema.marks;
145
- if (code) {
146
- return toggleMark(code)(state, dispatch);
147
- }
148
- return false;
149
- };
150
- };
151
- export const toggleCodeWithAnalytics = editorAnalyticsAPI => ({
152
- inputMethod
153
- }) => withAnalytics(editorAnalyticsAPI, {
154
- action: ACTION.FORMATTED,
155
- actionSubject: ACTION_SUBJECT.TEXT,
156
- eventType: EVENT_TYPE.TRACK,
157
- actionSubjectId: ACTION_SUBJECT_ID.FORMAT_CODE,
158
- attributes: {
159
- inputMethod
160
- }
161
- })(toggleCode());