@atlaskit/editor-core 187.3.5 → 187.4.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 +12 -0
- package/dist/cjs/plugins/text-formatting/commands/text-formatting.js +105 -88
- package/dist/cjs/plugins/text-formatting/index.js +8 -6
- package/dist/cjs/plugins/text-formatting/pm-plugins/keymap.js +8 -8
- package/dist/cjs/plugins/text-formatting/pm-plugins/main.js +5 -5
- package/dist/cjs/plugins/text-formatting/ui/Toolbar/hooks/formatting-icons.js +64 -59
- package/dist/cjs/plugins/text-formatting/ui/Toolbar/index.js +2 -1
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/plugins/text-formatting/commands/text-formatting.js +18 -17
- package/dist/es2019/plugins/text-formatting/index.js +12 -6
- package/dist/es2019/plugins/text-formatting/pm-plugins/keymap.js +8 -8
- package/dist/es2019/plugins/text-formatting/pm-plugins/main.js +5 -5
- package/dist/es2019/plugins/text-formatting/ui/Toolbar/hooks/formatting-icons.js +24 -21
- package/dist/es2019/plugins/text-formatting/ui/Toolbar/index.js +2 -1
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/plugins/text-formatting/commands/text-formatting.js +105 -88
- package/dist/esm/plugins/text-formatting/index.js +8 -6
- package/dist/esm/plugins/text-formatting/pm-plugins/keymap.js +8 -8
- package/dist/esm/plugins/text-formatting/pm-plugins/main.js +5 -5
- package/dist/esm/plugins/text-formatting/ui/Toolbar/hooks/formatting-icons.js +64 -59
- package/dist/esm/plugins/text-formatting/ui/Toolbar/index.js +2 -1
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/esm/version.json +1 -1
- package/dist/types/plugins/text-formatting/commands/text-formatting.d.ts +9 -9
- package/dist/types/plugins/text-formatting/pm-plugins/keymap.d.ts +2 -1
- package/dist/types/plugins/text-formatting/pm-plugins/main.d.ts +2 -1
- package/dist/types/plugins/text-formatting/ui/Toolbar/hooks/formatting-icons.d.ts +8 -3
- package/dist/types-ts4.5/plugins/text-formatting/commands/text-formatting.d.ts +9 -9
- package/dist/types-ts4.5/plugins/text-formatting/pm-plugins/keymap.d.ts +2 -1
- package/dist/types-ts4.5/plugins/text-formatting/pm-plugins/main.d.ts +2 -1
- package/dist/types-ts4.5/plugins/text-formatting/ui/Toolbar/hooks/formatting-icons.d.ts +8 -3
- package/package.json +1 -5
- package/report.api.md +21 -7
- package/tmp/api-report-tmp.d.ts +7 -7
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { Selection } from 'prosemirror-state';
|
|
2
2
|
import { applyMarkOnRange, toggleMark } from '../../../utils/commands';
|
|
3
|
-
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD
|
|
3
|
+
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
4
4
|
import { hasCode, markActive } from '../utils';
|
|
5
|
+
import { withAnalytics } from '@atlaskit/editor-common/editor-analytics';
|
|
5
6
|
export const moveRight = () => {
|
|
6
7
|
return (state, dispatch) => {
|
|
7
8
|
const {
|
|
@@ -117,9 +118,9 @@ export const toggleEm = () => {
|
|
|
117
118
|
return false;
|
|
118
119
|
};
|
|
119
120
|
};
|
|
120
|
-
export const toggleEmWithAnalytics = ({
|
|
121
|
+
export const toggleEmWithAnalytics = editorAnalyticsAPI => ({
|
|
121
122
|
inputMethod
|
|
122
|
-
}) => withAnalytics({
|
|
123
|
+
}) => withAnalytics(editorAnalyticsAPI, {
|
|
123
124
|
action: ACTION.FORMATTED,
|
|
124
125
|
actionSubject: ACTION_SUBJECT.TEXT,
|
|
125
126
|
eventType: EVENT_TYPE.TRACK,
|
|
@@ -139,9 +140,9 @@ export const toggleStrike = () => {
|
|
|
139
140
|
return false;
|
|
140
141
|
};
|
|
141
142
|
};
|
|
142
|
-
export const toggleStrikeWithAnalytics = ({
|
|
143
|
+
export const toggleStrikeWithAnalytics = editorAnalyticsAPI => ({
|
|
143
144
|
inputMethod
|
|
144
|
-
}) => withAnalytics({
|
|
145
|
+
}) => withAnalytics(editorAnalyticsAPI, {
|
|
145
146
|
action: ACTION.FORMATTED,
|
|
146
147
|
actionSubject: ACTION_SUBJECT.TEXT,
|
|
147
148
|
eventType: EVENT_TYPE.TRACK,
|
|
@@ -161,9 +162,9 @@ export const toggleStrong = () => {
|
|
|
161
162
|
return false;
|
|
162
163
|
};
|
|
163
164
|
};
|
|
164
|
-
export const toggleStrongWithAnalytics = ({
|
|
165
|
+
export const toggleStrongWithAnalytics = editorAnalyticsAPI => ({
|
|
165
166
|
inputMethod
|
|
166
|
-
}) => withAnalytics({
|
|
167
|
+
}) => withAnalytics(editorAnalyticsAPI, {
|
|
167
168
|
action: ACTION.FORMATTED,
|
|
168
169
|
actionSubject: ACTION_SUBJECT.TEXT,
|
|
169
170
|
eventType: EVENT_TYPE.TRACK,
|
|
@@ -183,9 +184,9 @@ export const toggleUnderline = () => {
|
|
|
183
184
|
return false;
|
|
184
185
|
};
|
|
185
186
|
};
|
|
186
|
-
export const toggleUnderlineWithAnalytics = ({
|
|
187
|
+
export const toggleUnderlineWithAnalytics = editorAnalyticsAPI => ({
|
|
187
188
|
inputMethod
|
|
188
|
-
}) => withAnalytics({
|
|
189
|
+
}) => withAnalytics(editorAnalyticsAPI, {
|
|
189
190
|
action: ACTION.FORMATTED,
|
|
190
191
|
actionSubject: ACTION_SUBJECT.TEXT,
|
|
191
192
|
eventType: EVENT_TYPE.TRACK,
|
|
@@ -207,9 +208,9 @@ export const toggleSuperscript = () => {
|
|
|
207
208
|
return false;
|
|
208
209
|
};
|
|
209
210
|
};
|
|
210
|
-
export const toggleSuperscriptWithAnalytics = ({
|
|
211
|
+
export const toggleSuperscriptWithAnalytics = editorAnalyticsAPI => ({
|
|
211
212
|
inputMethod
|
|
212
|
-
}) => withAnalytics({
|
|
213
|
+
}) => withAnalytics(editorAnalyticsAPI, {
|
|
213
214
|
action: ACTION.FORMATTED,
|
|
214
215
|
actionSubject: ACTION_SUBJECT.TEXT,
|
|
215
216
|
eventType: EVENT_TYPE.TRACK,
|
|
@@ -231,9 +232,9 @@ export const toggleSubscript = () => {
|
|
|
231
232
|
return false;
|
|
232
233
|
};
|
|
233
234
|
};
|
|
234
|
-
export const toggleSubscriptWithAnalytics = ({
|
|
235
|
+
export const toggleSubscriptWithAnalytics = editorAnalyticsAPI => ({
|
|
235
236
|
inputMethod
|
|
236
|
-
}) => withAnalytics({
|
|
237
|
+
}) => withAnalytics(editorAnalyticsAPI, {
|
|
237
238
|
action: ACTION.FORMATTED,
|
|
238
239
|
actionSubject: ACTION_SUBJECT.TEXT,
|
|
239
240
|
eventType: EVENT_TYPE.TRACK,
|
|
@@ -253,9 +254,9 @@ export const toggleCode = () => {
|
|
|
253
254
|
return false;
|
|
254
255
|
};
|
|
255
256
|
};
|
|
256
|
-
export const toggleCodeWithAnalytics = ({
|
|
257
|
+
export const toggleCodeWithAnalytics = editorAnalyticsAPI => ({
|
|
257
258
|
inputMethod
|
|
258
|
-
}) => withAnalytics({
|
|
259
|
+
}) => withAnalytics(editorAnalyticsAPI, {
|
|
259
260
|
action: ACTION.FORMATTED,
|
|
260
261
|
actionSubject: ACTION_SUBJECT.TEXT,
|
|
261
262
|
eventType: EVENT_TYPE.TRACK,
|
|
@@ -288,8 +289,8 @@ const createInlineCodeFromTextInput = (from, to, text) => {
|
|
|
288
289
|
return false;
|
|
289
290
|
};
|
|
290
291
|
};
|
|
291
|
-
export const createInlineCodeFromTextInputWithAnalytics = (from, to, text) => {
|
|
292
|
-
return withAnalytics({
|
|
292
|
+
export const createInlineCodeFromTextInputWithAnalytics = editorAnalyticsAPI => (from, to, text) => {
|
|
293
|
+
return withAnalytics(editorAnalyticsAPI, {
|
|
293
294
|
action: ACTION.FORMATTED,
|
|
294
295
|
actionSubject: ACTION_SUBJECT.TEXT,
|
|
295
296
|
eventType: EVENT_TYPE.TRACK,
|
|
@@ -37,7 +37,10 @@ const textFormatting = (options = {}, api) => ({
|
|
|
37
37
|
name: 'textFormatting',
|
|
38
38
|
plugin: ({
|
|
39
39
|
dispatch
|
|
40
|
-
}) =>
|
|
40
|
+
}) => {
|
|
41
|
+
var _api$dependencies$ana;
|
|
42
|
+
return textFormattingPlugin(dispatch, api === null || api === void 0 ? void 0 : (_api$dependencies$ana = api.dependencies.analytics) === null || _api$dependencies$ana === void 0 ? void 0 : _api$dependencies$ana.actions);
|
|
43
|
+
}
|
|
41
44
|
}, {
|
|
42
45
|
name: 'textFormattingCursor',
|
|
43
46
|
plugin: () => textFormattingCursorPlugin
|
|
@@ -60,14 +63,17 @@ const textFormatting = (options = {}, api) => ({
|
|
|
60
63
|
}, {
|
|
61
64
|
name: 'textFormattingClearKeymap',
|
|
62
65
|
plugin: () => {
|
|
63
|
-
var _api$dependencies$
|
|
64
|
-
return clearFormattingKeymapPlugin(api === null || api === void 0 ? void 0 : (_api$dependencies$
|
|
66
|
+
var _api$dependencies$ana2;
|
|
67
|
+
return clearFormattingKeymapPlugin(api === null || api === void 0 ? void 0 : (_api$dependencies$ana2 = api.dependencies.analytics) === null || _api$dependencies$ana2 === void 0 ? void 0 : _api$dependencies$ana2.actions);
|
|
65
68
|
}
|
|
66
69
|
}, {
|
|
67
70
|
name: 'textFormattingKeymap',
|
|
68
71
|
plugin: ({
|
|
69
72
|
schema
|
|
70
|
-
}) =>
|
|
73
|
+
}) => {
|
|
74
|
+
var _api$dependencies$ana3;
|
|
75
|
+
return keymapPlugin(schema, api === null || api === void 0 ? void 0 : (_api$dependencies$ana3 = api.dependencies.analytics) === null || _api$dependencies$ana3 === void 0 ? void 0 : _api$dependencies$ana3.actions);
|
|
76
|
+
}
|
|
71
77
|
}];
|
|
72
78
|
},
|
|
73
79
|
primaryToolbarComponent({
|
|
@@ -84,7 +90,7 @@ const textFormatting = (options = {}, api) => ({
|
|
|
84
90
|
clearFormattingPluginState: clearFormattingPluginKey
|
|
85
91
|
},
|
|
86
92
|
render: () => {
|
|
87
|
-
var _api$dependencies$
|
|
93
|
+
var _api$dependencies$ana4;
|
|
88
94
|
return /*#__PURE__*/React.createElement(Toolbar, {
|
|
89
95
|
editorState: editorView.state,
|
|
90
96
|
popupsMountPoint: popupsMountPoint,
|
|
@@ -94,7 +100,7 @@ const textFormatting = (options = {}, api) => ({
|
|
|
94
100
|
editorView: editorView,
|
|
95
101
|
isToolbarDisabled: disabled,
|
|
96
102
|
shouldUseResponsiveToolbar: Boolean(options.responsiveToolbarMenu),
|
|
97
|
-
editorAnalyticsAPI: api === null || api === void 0 ? void 0 : (_api$dependencies$
|
|
103
|
+
editorAnalyticsAPI: api === null || api === void 0 ? void 0 : (_api$dependencies$ana4 = api.dependencies.analytics) === null || _api$dependencies$ana4 === void 0 ? void 0 : _api$dependencies$ana4.actions
|
|
98
104
|
});
|
|
99
105
|
}
|
|
100
106
|
});
|
|
@@ -2,40 +2,40 @@ import * as keymaps from '../../../keymaps';
|
|
|
2
2
|
import { keymap } from '../../../utils/keymap';
|
|
3
3
|
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
4
4
|
import * as commands from '../commands/text-formatting';
|
|
5
|
-
export default function keymapPlugin(schema) {
|
|
5
|
+
export default function keymapPlugin(schema, editorAnalyticsAPI) {
|
|
6
6
|
const list = {};
|
|
7
7
|
if (schema.marks.strong) {
|
|
8
|
-
keymaps.bindKeymapWithCommand(keymaps.toggleBold.common, commands.toggleStrongWithAnalytics({
|
|
8
|
+
keymaps.bindKeymapWithCommand(keymaps.toggleBold.common, commands.toggleStrongWithAnalytics(editorAnalyticsAPI)({
|
|
9
9
|
inputMethod: INPUT_METHOD.SHORTCUT
|
|
10
10
|
}), list);
|
|
11
11
|
}
|
|
12
12
|
if (schema.marks.em) {
|
|
13
|
-
keymaps.bindKeymapWithCommand(keymaps.toggleItalic.common, commands.toggleEmWithAnalytics({
|
|
13
|
+
keymaps.bindKeymapWithCommand(keymaps.toggleItalic.common, commands.toggleEmWithAnalytics(editorAnalyticsAPI)({
|
|
14
14
|
inputMethod: INPUT_METHOD.SHORTCUT
|
|
15
15
|
}), list);
|
|
16
16
|
}
|
|
17
17
|
if (schema.marks.code) {
|
|
18
|
-
keymaps.bindKeymapWithCommand(keymaps.toggleCode.common, commands.toggleCodeWithAnalytics({
|
|
18
|
+
keymaps.bindKeymapWithCommand(keymaps.toggleCode.common, commands.toggleCodeWithAnalytics(editorAnalyticsAPI)({
|
|
19
19
|
inputMethod: INPUT_METHOD.SHORTCUT
|
|
20
20
|
}), list);
|
|
21
21
|
}
|
|
22
22
|
if (schema.marks.strike) {
|
|
23
|
-
keymaps.bindKeymapWithCommand(keymaps.toggleStrikethrough.common, commands.toggleStrikeWithAnalytics({
|
|
23
|
+
keymaps.bindKeymapWithCommand(keymaps.toggleStrikethrough.common, commands.toggleStrikeWithAnalytics(editorAnalyticsAPI)({
|
|
24
24
|
inputMethod: INPUT_METHOD.SHORTCUT
|
|
25
25
|
}), list);
|
|
26
26
|
}
|
|
27
27
|
if (schema.marks.subsup) {
|
|
28
|
-
keymaps.bindKeymapWithCommand(keymaps.toggleSubscript.common, commands.toggleSubscriptWithAnalytics({
|
|
28
|
+
keymaps.bindKeymapWithCommand(keymaps.toggleSubscript.common, commands.toggleSubscriptWithAnalytics(editorAnalyticsAPI)({
|
|
29
29
|
inputMethod: INPUT_METHOD.SHORTCUT
|
|
30
30
|
}), list);
|
|
31
31
|
}
|
|
32
32
|
if (schema.marks.subsup) {
|
|
33
|
-
keymaps.bindKeymapWithCommand(keymaps.toggleSuperscript.common, commands.toggleSuperscriptWithAnalytics({
|
|
33
|
+
keymaps.bindKeymapWithCommand(keymaps.toggleSuperscript.common, commands.toggleSuperscriptWithAnalytics(editorAnalyticsAPI)({
|
|
34
34
|
inputMethod: INPUT_METHOD.SHORTCUT
|
|
35
35
|
}), list);
|
|
36
36
|
}
|
|
37
37
|
if (schema.marks.underline) {
|
|
38
|
-
keymaps.bindKeymapWithCommand(keymaps.toggleUnderline.common, commands.toggleUnderlineWithAnalytics({
|
|
38
|
+
keymaps.bindKeymapWithCommand(keymaps.toggleUnderline.common, commands.toggleUnderlineWithAnalytics(editorAnalyticsAPI)({
|
|
39
39
|
inputMethod: INPUT_METHOD.SHORTCUT
|
|
40
40
|
}), list);
|
|
41
41
|
}
|
|
@@ -8,7 +8,7 @@ import * as commands from '../commands/text-formatting';
|
|
|
8
8
|
import { anyMarkActive } from '../utils';
|
|
9
9
|
import { pluginKey } from './plugin-key';
|
|
10
10
|
export { pluginKey };
|
|
11
|
-
const getTextFormattingState = editorState => {
|
|
11
|
+
const getTextFormattingState = (editorState, editorAnalyticsAPI) => {
|
|
12
12
|
const {
|
|
13
13
|
em,
|
|
14
14
|
code,
|
|
@@ -56,13 +56,13 @@ const getTextFormattingState = editorState => {
|
|
|
56
56
|
}
|
|
57
57
|
return state;
|
|
58
58
|
};
|
|
59
|
-
export const plugin = dispatch => new SafePlugin({
|
|
59
|
+
export const plugin = (dispatch, editorAnalyticsAPI) => new SafePlugin({
|
|
60
60
|
state: {
|
|
61
61
|
init(_config, state) {
|
|
62
|
-
return getTextFormattingState(state);
|
|
62
|
+
return getTextFormattingState(state, editorAnalyticsAPI);
|
|
63
63
|
},
|
|
64
64
|
apply(_tr, pluginState, _oldState, newState) {
|
|
65
|
-
const state = getTextFormattingState(newState);
|
|
65
|
+
const state = getTextFormattingState(newState, editorAnalyticsAPI);
|
|
66
66
|
if (!shallowEqual(pluginState, state)) {
|
|
67
67
|
dispatch(pluginKey, state);
|
|
68
68
|
return state;
|
|
@@ -100,7 +100,7 @@ export const plugin = dispatch => new SafePlugin({
|
|
|
100
100
|
}
|
|
101
101
|
} = state;
|
|
102
102
|
if (parentNodeType.allowsMarkType(schema.marks.code)) {
|
|
103
|
-
return createInlineCodeFromTextInputWithAnalytics(from, to, text)(state, dispatch);
|
|
103
|
+
return createInlineCodeFromTextInputWithAnalytics(editorAnalyticsAPI)(from, to, text)(state, dispatch);
|
|
104
104
|
}
|
|
105
105
|
return false;
|
|
106
106
|
}
|
|
@@ -15,10 +15,10 @@ import { getAriaKeyshortcuts } from '@atlaskit/editor-common/keymaps';
|
|
|
15
15
|
const withToolbarInputMethod = func => func({
|
|
16
16
|
inputMethod: INPUT_METHOD.TOOLBAR
|
|
17
17
|
});
|
|
18
|
-
const IconButtons = {
|
|
18
|
+
const IconButtons = editorAnalyticsAPI => ({
|
|
19
19
|
strong: {
|
|
20
20
|
buttonId: TOOLBAR_ACTION_SUBJECT_ID.TEXT_FORMATTING_STRONG,
|
|
21
|
-
command: withToolbarInputMethod(commands.toggleStrongWithAnalytics),
|
|
21
|
+
command: withToolbarInputMethod(commands.toggleStrongWithAnalytics(editorAnalyticsAPI)),
|
|
22
22
|
message: toolbarMessages.bold,
|
|
23
23
|
tooltipKeymap: toggleBold,
|
|
24
24
|
component: () => jsx(BoldIcon, {
|
|
@@ -27,7 +27,7 @@ const IconButtons = {
|
|
|
27
27
|
},
|
|
28
28
|
em: {
|
|
29
29
|
buttonId: TOOLBAR_ACTION_SUBJECT_ID.TEXT_FORMATTING_ITALIC,
|
|
30
|
-
command: withToolbarInputMethod(commands.toggleEmWithAnalytics),
|
|
30
|
+
command: withToolbarInputMethod(commands.toggleEmWithAnalytics(editorAnalyticsAPI)),
|
|
31
31
|
message: toolbarMessages.italic,
|
|
32
32
|
tooltipKeymap: toggleItalic,
|
|
33
33
|
component: () => jsx(ItalicIcon, {
|
|
@@ -35,38 +35,39 @@ const IconButtons = {
|
|
|
35
35
|
})
|
|
36
36
|
},
|
|
37
37
|
underline: {
|
|
38
|
-
command: withToolbarInputMethod(commands.toggleUnderlineWithAnalytics),
|
|
38
|
+
command: withToolbarInputMethod(commands.toggleUnderlineWithAnalytics(editorAnalyticsAPI)),
|
|
39
39
|
message: toolbarMessages.underline,
|
|
40
40
|
tooltipKeymap: toggleUnderline
|
|
41
41
|
},
|
|
42
42
|
strike: {
|
|
43
|
-
command: withToolbarInputMethod(commands.toggleStrikeWithAnalytics),
|
|
43
|
+
command: withToolbarInputMethod(commands.toggleStrikeWithAnalytics(editorAnalyticsAPI)),
|
|
44
44
|
message: toolbarMessages.strike,
|
|
45
45
|
tooltipKeymap: toggleStrikethrough
|
|
46
46
|
},
|
|
47
47
|
code: {
|
|
48
|
-
command: withToolbarInputMethod(commands.toggleCodeWithAnalytics),
|
|
48
|
+
command: withToolbarInputMethod(commands.toggleCodeWithAnalytics(editorAnalyticsAPI)),
|
|
49
49
|
message: toolbarMessages.code,
|
|
50
50
|
tooltipKeymap: toggleCode
|
|
51
51
|
},
|
|
52
52
|
subscript: {
|
|
53
|
-
command: withToolbarInputMethod(commands.toggleSubscriptWithAnalytics),
|
|
53
|
+
command: withToolbarInputMethod(commands.toggleSubscriptWithAnalytics(editorAnalyticsAPI)),
|
|
54
54
|
message: toolbarMessages.subscript,
|
|
55
55
|
tooltipKeymap: toggleSubscript
|
|
56
56
|
},
|
|
57
57
|
superscript: {
|
|
58
|
-
command: withToolbarInputMethod(commands.toggleSuperscriptWithAnalytics),
|
|
58
|
+
command: withToolbarInputMethod(commands.toggleSuperscriptWithAnalytics(editorAnalyticsAPI)),
|
|
59
59
|
message: toolbarMessages.superscript,
|
|
60
60
|
tooltipKeymap: toggleSuperscript
|
|
61
61
|
}
|
|
62
|
-
};
|
|
62
|
+
});
|
|
63
63
|
const getIcon = ({
|
|
64
64
|
iconType,
|
|
65
65
|
isDisabled,
|
|
66
66
|
isActive,
|
|
67
|
-
intl
|
|
67
|
+
intl,
|
|
68
|
+
editorAnalyticsAPI
|
|
68
69
|
}) => {
|
|
69
|
-
const icon = IconButtons[iconType];
|
|
70
|
+
const icon = IconButtons(editorAnalyticsAPI)[iconType];
|
|
70
71
|
const content = intl.formatMessage(icon.message);
|
|
71
72
|
const {
|
|
72
73
|
tooltipKeymap
|
|
@@ -128,7 +129,7 @@ const buildMenuIconState = iconMark => ({
|
|
|
128
129
|
hasSchemaMark
|
|
129
130
|
};
|
|
130
131
|
};
|
|
131
|
-
const buildIcon = iconMark => {
|
|
132
|
+
const buildIcon = (iconMark, editorAnalyticsAPI) => {
|
|
132
133
|
const getState = buildMenuIconState(iconMark);
|
|
133
134
|
return ({
|
|
134
135
|
schema,
|
|
@@ -150,19 +151,13 @@ const buildIcon = iconMark => {
|
|
|
150
151
|
iconType: IconTypes[iconMark],
|
|
151
152
|
isDisabled: isToolbarDisabled || isDisabled,
|
|
152
153
|
isActive,
|
|
153
|
-
intl
|
|
154
|
+
intl,
|
|
155
|
+
editorAnalyticsAPI
|
|
154
156
|
}), [isToolbarDisabled, isDisabled, isActive, intl]);
|
|
155
157
|
const shouldRenderIcon = hasSchemaMark && !isHidden;
|
|
156
158
|
return useMemo(() => shouldRenderIcon ? iconComponent : null, [shouldRenderIcon, iconComponent]);
|
|
157
159
|
};
|
|
158
160
|
};
|
|
159
|
-
const buildStrongIcon = buildIcon(IconTypes.strong);
|
|
160
|
-
const buildEmIcon = buildIcon(IconTypes.em);
|
|
161
|
-
const buildUnderlineIcon = buildIcon(IconTypes.underline);
|
|
162
|
-
const buildStrikeIcon = buildIcon(IconTypes.strike);
|
|
163
|
-
const buildCodeIcon = buildIcon(IconTypes.code);
|
|
164
|
-
const buildSubscriptIcon = buildIcon(IconTypes.subscript);
|
|
165
|
-
const buildSuperscriptIcon = buildIcon(IconTypes.superscript);
|
|
166
161
|
const useTextFormattingPluginState = editorState => useMemo(() => {
|
|
167
162
|
const pluginState = textFormattingPluginKey.getState(editorState);
|
|
168
163
|
|
|
@@ -172,7 +167,8 @@ const useTextFormattingPluginState = editorState => useMemo(() => {
|
|
|
172
167
|
export const useFormattingIcons = ({
|
|
173
168
|
isToolbarDisabled,
|
|
174
169
|
editorState,
|
|
175
|
-
intl
|
|
170
|
+
intl,
|
|
171
|
+
editorAnalyticsAPI
|
|
176
172
|
}) => {
|
|
177
173
|
const textFormattingPluginState = useTextFormattingPluginState(editorState);
|
|
178
174
|
const {
|
|
@@ -184,6 +180,13 @@ export const useFormattingIcons = ({
|
|
|
184
180
|
intl,
|
|
185
181
|
isToolbarDisabled: Boolean(isToolbarDisabled)
|
|
186
182
|
};
|
|
183
|
+
const buildStrongIcon = buildIcon(IconTypes.strong, editorAnalyticsAPI);
|
|
184
|
+
const buildEmIcon = buildIcon(IconTypes.em, editorAnalyticsAPI);
|
|
185
|
+
const buildUnderlineIcon = buildIcon(IconTypes.underline, editorAnalyticsAPI);
|
|
186
|
+
const buildStrikeIcon = buildIcon(IconTypes.strike, editorAnalyticsAPI);
|
|
187
|
+
const buildCodeIcon = buildIcon(IconTypes.code, editorAnalyticsAPI);
|
|
188
|
+
const buildSubscriptIcon = buildIcon(IconTypes.subscript, editorAnalyticsAPI);
|
|
189
|
+
const buildSuperscriptIcon = buildIcon(IconTypes.superscript, editorAnalyticsAPI);
|
|
187
190
|
const strongIcon = buildStrongIcon(props);
|
|
188
191
|
const emIcon = buildEmIcon(props);
|
|
189
192
|
const underlineIcon = buildUnderlineIcon(props);
|
package/dist/es2019/version.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { Selection } from 'prosemirror-state';
|
|
2
2
|
import { applyMarkOnRange, toggleMark } from '../../../utils/commands';
|
|
3
|
-
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD
|
|
3
|
+
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
4
4
|
import { hasCode, markActive } from '../utils';
|
|
5
|
+
import { withAnalytics } from '@atlaskit/editor-common/editor-analytics';
|
|
5
6
|
export var moveRight = function moveRight() {
|
|
6
7
|
return function (state, dispatch) {
|
|
7
8
|
var code = state.schema.marks.code;
|
|
@@ -105,17 +106,19 @@ export var toggleEm = function toggleEm() {
|
|
|
105
106
|
return false;
|
|
106
107
|
};
|
|
107
108
|
};
|
|
108
|
-
export var toggleEmWithAnalytics = function toggleEmWithAnalytics(
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
109
|
+
export var toggleEmWithAnalytics = function toggleEmWithAnalytics(editorAnalyticsAPI) {
|
|
110
|
+
return function (_ref3) {
|
|
111
|
+
var inputMethod = _ref3.inputMethod;
|
|
112
|
+
return withAnalytics(editorAnalyticsAPI, {
|
|
113
|
+
action: ACTION.FORMATTED,
|
|
114
|
+
actionSubject: ACTION_SUBJECT.TEXT,
|
|
115
|
+
eventType: EVENT_TYPE.TRACK,
|
|
116
|
+
actionSubjectId: ACTION_SUBJECT_ID.FORMAT_ITALIC,
|
|
117
|
+
attributes: {
|
|
118
|
+
inputMethod: inputMethod
|
|
119
|
+
}
|
|
120
|
+
})(toggleEm());
|
|
121
|
+
};
|
|
119
122
|
};
|
|
120
123
|
export var toggleStrike = function toggleStrike() {
|
|
121
124
|
return function (state, dispatch) {
|
|
@@ -126,17 +129,19 @@ export var toggleStrike = function toggleStrike() {
|
|
|
126
129
|
return false;
|
|
127
130
|
};
|
|
128
131
|
};
|
|
129
|
-
export var toggleStrikeWithAnalytics = function toggleStrikeWithAnalytics(
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
132
|
+
export var toggleStrikeWithAnalytics = function toggleStrikeWithAnalytics(editorAnalyticsAPI) {
|
|
133
|
+
return function (_ref4) {
|
|
134
|
+
var inputMethod = _ref4.inputMethod;
|
|
135
|
+
return withAnalytics(editorAnalyticsAPI, {
|
|
136
|
+
action: ACTION.FORMATTED,
|
|
137
|
+
actionSubject: ACTION_SUBJECT.TEXT,
|
|
138
|
+
eventType: EVENT_TYPE.TRACK,
|
|
139
|
+
actionSubjectId: ACTION_SUBJECT_ID.FORMAT_STRIKE,
|
|
140
|
+
attributes: {
|
|
141
|
+
inputMethod: inputMethod
|
|
142
|
+
}
|
|
143
|
+
})(toggleStrike());
|
|
144
|
+
};
|
|
140
145
|
};
|
|
141
146
|
export var toggleStrong = function toggleStrong() {
|
|
142
147
|
return function (state, dispatch) {
|
|
@@ -147,17 +152,19 @@ export var toggleStrong = function toggleStrong() {
|
|
|
147
152
|
return false;
|
|
148
153
|
};
|
|
149
154
|
};
|
|
150
|
-
export var toggleStrongWithAnalytics = function toggleStrongWithAnalytics(
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
155
|
+
export var toggleStrongWithAnalytics = function toggleStrongWithAnalytics(editorAnalyticsAPI) {
|
|
156
|
+
return function (_ref5) {
|
|
157
|
+
var inputMethod = _ref5.inputMethod;
|
|
158
|
+
return withAnalytics(editorAnalyticsAPI, {
|
|
159
|
+
action: ACTION.FORMATTED,
|
|
160
|
+
actionSubject: ACTION_SUBJECT.TEXT,
|
|
161
|
+
eventType: EVENT_TYPE.TRACK,
|
|
162
|
+
actionSubjectId: ACTION_SUBJECT_ID.FORMAT_STRONG,
|
|
163
|
+
attributes: {
|
|
164
|
+
inputMethod: inputMethod
|
|
165
|
+
}
|
|
166
|
+
})(toggleStrong());
|
|
167
|
+
};
|
|
161
168
|
};
|
|
162
169
|
export var toggleUnderline = function toggleUnderline() {
|
|
163
170
|
return function (state, dispatch) {
|
|
@@ -168,17 +175,19 @@ export var toggleUnderline = function toggleUnderline() {
|
|
|
168
175
|
return false;
|
|
169
176
|
};
|
|
170
177
|
};
|
|
171
|
-
export var toggleUnderlineWithAnalytics = function toggleUnderlineWithAnalytics(
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
178
|
+
export var toggleUnderlineWithAnalytics = function toggleUnderlineWithAnalytics(editorAnalyticsAPI) {
|
|
179
|
+
return function (_ref6) {
|
|
180
|
+
var inputMethod = _ref6.inputMethod;
|
|
181
|
+
return withAnalytics(editorAnalyticsAPI, {
|
|
182
|
+
action: ACTION.FORMATTED,
|
|
183
|
+
actionSubject: ACTION_SUBJECT.TEXT,
|
|
184
|
+
eventType: EVENT_TYPE.TRACK,
|
|
185
|
+
actionSubjectId: ACTION_SUBJECT_ID.FORMAT_UNDERLINE,
|
|
186
|
+
attributes: {
|
|
187
|
+
inputMethod: inputMethod
|
|
188
|
+
}
|
|
189
|
+
})(toggleUnderline());
|
|
190
|
+
};
|
|
182
191
|
};
|
|
183
192
|
export var toggleSuperscript = function toggleSuperscript() {
|
|
184
193
|
return function (state, dispatch) {
|
|
@@ -191,17 +200,19 @@ export var toggleSuperscript = function toggleSuperscript() {
|
|
|
191
200
|
return false;
|
|
192
201
|
};
|
|
193
202
|
};
|
|
194
|
-
export var toggleSuperscriptWithAnalytics = function toggleSuperscriptWithAnalytics(
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
203
|
+
export var toggleSuperscriptWithAnalytics = function toggleSuperscriptWithAnalytics(editorAnalyticsAPI) {
|
|
204
|
+
return function (_ref7) {
|
|
205
|
+
var inputMethod = _ref7.inputMethod;
|
|
206
|
+
return withAnalytics(editorAnalyticsAPI, {
|
|
207
|
+
action: ACTION.FORMATTED,
|
|
208
|
+
actionSubject: ACTION_SUBJECT.TEXT,
|
|
209
|
+
eventType: EVENT_TYPE.TRACK,
|
|
210
|
+
actionSubjectId: ACTION_SUBJECT_ID.FORMAT_SUPER,
|
|
211
|
+
attributes: {
|
|
212
|
+
inputMethod: inputMethod
|
|
213
|
+
}
|
|
214
|
+
})(toggleSuperscript());
|
|
215
|
+
};
|
|
205
216
|
};
|
|
206
217
|
export var toggleSubscript = function toggleSubscript() {
|
|
207
218
|
return function (state, dispatch) {
|
|
@@ -214,17 +225,19 @@ export var toggleSubscript = function toggleSubscript() {
|
|
|
214
225
|
return false;
|
|
215
226
|
};
|
|
216
227
|
};
|
|
217
|
-
export var toggleSubscriptWithAnalytics = function toggleSubscriptWithAnalytics(
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
+
export var toggleSubscriptWithAnalytics = function toggleSubscriptWithAnalytics(editorAnalyticsAPI) {
|
|
229
|
+
return function (_ref8) {
|
|
230
|
+
var inputMethod = _ref8.inputMethod;
|
|
231
|
+
return withAnalytics(editorAnalyticsAPI, {
|
|
232
|
+
action: ACTION.FORMATTED,
|
|
233
|
+
actionSubject: ACTION_SUBJECT.TEXT,
|
|
234
|
+
eventType: EVENT_TYPE.TRACK,
|
|
235
|
+
actionSubjectId: ACTION_SUBJECT_ID.FORMAT_SUB,
|
|
236
|
+
attributes: {
|
|
237
|
+
inputMethod: inputMethod
|
|
238
|
+
}
|
|
239
|
+
})(toggleSubscript());
|
|
240
|
+
};
|
|
228
241
|
};
|
|
229
242
|
export var toggleCode = function toggleCode() {
|
|
230
243
|
return function (state, dispatch) {
|
|
@@ -235,17 +248,19 @@ export var toggleCode = function toggleCode() {
|
|
|
235
248
|
return false;
|
|
236
249
|
};
|
|
237
250
|
};
|
|
238
|
-
export var toggleCodeWithAnalytics = function toggleCodeWithAnalytics(
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
251
|
+
export var toggleCodeWithAnalytics = function toggleCodeWithAnalytics(editorAnalyticsAPI) {
|
|
252
|
+
return function (_ref9) {
|
|
253
|
+
var inputMethod = _ref9.inputMethod;
|
|
254
|
+
return withAnalytics(editorAnalyticsAPI, {
|
|
255
|
+
action: ACTION.FORMATTED,
|
|
256
|
+
actionSubject: ACTION_SUBJECT.TEXT,
|
|
257
|
+
eventType: EVENT_TYPE.TRACK,
|
|
258
|
+
actionSubjectId: ACTION_SUBJECT_ID.FORMAT_CODE,
|
|
259
|
+
attributes: {
|
|
260
|
+
inputMethod: inputMethod
|
|
261
|
+
}
|
|
262
|
+
})(toggleCode());
|
|
263
|
+
};
|
|
249
264
|
};
|
|
250
265
|
var createInlineCodeFromTextInput = function createInlineCodeFromTextInput(from, to, text) {
|
|
251
266
|
return function (state, dispatch) {
|
|
@@ -269,14 +284,16 @@ var createInlineCodeFromTextInput = function createInlineCodeFromTextInput(from,
|
|
|
269
284
|
return false;
|
|
270
285
|
};
|
|
271
286
|
};
|
|
272
|
-
export var createInlineCodeFromTextInputWithAnalytics = function createInlineCodeFromTextInputWithAnalytics(
|
|
273
|
-
return
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
287
|
+
export var createInlineCodeFromTextInputWithAnalytics = function createInlineCodeFromTextInputWithAnalytics(editorAnalyticsAPI) {
|
|
288
|
+
return function (from, to, text) {
|
|
289
|
+
return withAnalytics(editorAnalyticsAPI, {
|
|
290
|
+
action: ACTION.FORMATTED,
|
|
291
|
+
actionSubject: ACTION_SUBJECT.TEXT,
|
|
292
|
+
eventType: EVENT_TYPE.TRACK,
|
|
293
|
+
actionSubjectId: ACTION_SUBJECT_ID.FORMAT_CODE,
|
|
294
|
+
attributes: {
|
|
295
|
+
inputMethod: INPUT_METHOD.FORMATTING
|
|
296
|
+
}
|
|
297
|
+
})(createInlineCodeFromTextInput(from, to, text));
|
|
298
|
+
};
|
|
282
299
|
};
|