@atlaskit/editor-core 187.10.8 → 187.11.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.
Files changed (88) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/dist/cjs/index.js +2 -94
  3. package/dist/cjs/plugins/help-dialog/ui/index.js +42 -42
  4. package/dist/cjs/plugins/paste/handlers.js +4 -6
  5. package/dist/cjs/plugins/text-formatting/actions.js +188 -0
  6. package/dist/cjs/plugins/text-formatting/commands/text-formatting.js +1 -180
  7. package/dist/cjs/plugins/text-formatting/index.js +17 -0
  8. package/dist/cjs/plugins/text-formatting/pm-plugins/keymap.js +8 -8
  9. package/dist/cjs/plugins/text-formatting/pm-plugins/main.js +8 -8
  10. package/dist/cjs/plugins/text-formatting/ui/Toolbar/hooks/clear-formatting-icon.js +2 -2
  11. package/dist/cjs/plugins/text-formatting/ui/Toolbar/hooks/formatting-icons.js +16 -16
  12. package/dist/cjs/plugins/text-formatting/ui/Toolbar/index.js +8 -8
  13. package/dist/cjs/plugins/text-formatting/utils.js +8 -36
  14. package/dist/cjs/ui/ContentStyles/index.js +8 -9
  15. package/dist/cjs/version-wrapper.js +1 -1
  16. package/dist/cjs/version.json +1 -1
  17. package/dist/es2019/index.js +0 -2
  18. package/dist/es2019/plugins/help-dialog/ui/index.js +1 -1
  19. package/dist/es2019/plugins/paste/handlers.js +5 -7
  20. package/dist/es2019/plugins/text-formatting/actions.js +161 -0
  21. package/dist/es2019/plugins/text-formatting/commands/text-formatting.js +1 -159
  22. package/dist/es2019/plugins/text-formatting/index.js +17 -0
  23. package/dist/es2019/plugins/text-formatting/pm-plugins/keymap.js +8 -8
  24. package/dist/es2019/plugins/text-formatting/pm-plugins/main.js +1 -1
  25. package/dist/es2019/plugins/text-formatting/ui/Toolbar/hooks/clear-formatting-icon.js +1 -1
  26. package/dist/es2019/plugins/text-formatting/ui/Toolbar/hooks/formatting-icons.js +9 -9
  27. package/dist/es2019/plugins/text-formatting/ui/Toolbar/index.js +1 -1
  28. package/dist/es2019/plugins/text-formatting/utils.js +1 -29
  29. package/dist/es2019/ui/ContentStyles/index.js +2 -3
  30. package/dist/es2019/version-wrapper.js +1 -1
  31. package/dist/es2019/version.json +1 -1
  32. package/dist/esm/index.js +0 -2
  33. package/dist/esm/plugins/help-dialog/ui/index.js +1 -1
  34. package/dist/esm/plugins/paste/handlers.js +5 -7
  35. package/dist/esm/plugins/text-formatting/actions.js +168 -0
  36. package/dist/esm/plugins/text-formatting/commands/text-formatting.js +1 -166
  37. package/dist/esm/plugins/text-formatting/index.js +17 -0
  38. package/dist/esm/plugins/text-formatting/pm-plugins/keymap.js +8 -8
  39. package/dist/esm/plugins/text-formatting/pm-plugins/main.js +1 -1
  40. package/dist/esm/plugins/text-formatting/ui/Toolbar/hooks/clear-formatting-icon.js +1 -1
  41. package/dist/esm/plugins/text-formatting/ui/Toolbar/hooks/formatting-icons.js +9 -9
  42. package/dist/esm/plugins/text-formatting/ui/Toolbar/index.js +1 -1
  43. package/dist/esm/plugins/text-formatting/utils.js +6 -33
  44. package/dist/esm/ui/ContentStyles/index.js +2 -3
  45. package/dist/esm/version-wrapper.js +1 -1
  46. package/dist/esm/version.json +1 -1
  47. package/dist/types/index.d.ts +6 -4
  48. package/dist/types/labs/next/presets/default.d.ts +78 -15
  49. package/dist/types/plugins/media/ui/ResizableMediaSingle/guidelines.d.ts +1 -1
  50. package/dist/types/plugins/paste/handlers.d.ts +1 -2
  51. package/dist/types/plugins/text-formatting/actions.d.ts +20 -0
  52. package/dist/types/plugins/text-formatting/commands/text-formatting.d.ts +0 -31
  53. package/dist/types/plugins/text-formatting/index.d.ts +18 -2
  54. package/dist/types/plugins/text-formatting/pm-plugins/main.d.ts +1 -2
  55. package/dist/types/plugins/text-formatting/pm-plugins/plugin-key.d.ts +1 -1
  56. package/dist/types/plugins/text-formatting/utils.d.ts +1 -5
  57. package/dist/types/types/editor-props.d.ts +1 -2
  58. package/dist/types/ui/ContentStyles/index.d.ts +1 -1
  59. package/dist/types-ts4.5/index.d.ts +6 -4
  60. package/dist/types-ts4.5/labs/next/presets/default.d.ts +78 -15
  61. package/dist/types-ts4.5/plugins/media/ui/ResizableMediaSingle/guidelines.d.ts +1 -1
  62. package/dist/types-ts4.5/plugins/paste/handlers.d.ts +1 -2
  63. package/dist/types-ts4.5/plugins/text-formatting/actions.d.ts +20 -0
  64. package/dist/types-ts4.5/plugins/text-formatting/commands/text-formatting.d.ts +0 -31
  65. package/dist/types-ts4.5/plugins/text-formatting/index.d.ts +18 -2
  66. package/dist/types-ts4.5/plugins/text-formatting/pm-plugins/main.d.ts +1 -2
  67. package/dist/types-ts4.5/plugins/text-formatting/pm-plugins/plugin-key.d.ts +1 -1
  68. package/dist/types-ts4.5/plugins/text-formatting/utils.d.ts +1 -5
  69. package/dist/types-ts4.5/types/editor-props.d.ts +1 -2
  70. package/dist/types-ts4.5/ui/ContentStyles/index.d.ts +1 -1
  71. package/package.json +2 -2
  72. package/report.api.md +31 -145
  73. package/tmp/api-report-tmp.d.ts +30 -118
  74. package/dist/cjs/plugins/text-formatting/styles.js +0 -15
  75. package/dist/cjs/plugins/text-formatting/types.js +0 -5
  76. package/dist/cjs/plugins/text-formatting/ui/Toolbar/toolbar-messages.js +0 -95
  77. package/dist/es2019/plugins/text-formatting/styles.js +0 -5
  78. package/dist/es2019/plugins/text-formatting/types.js +0 -1
  79. package/dist/es2019/plugins/text-formatting/ui/Toolbar/toolbar-messages.js +0 -88
  80. package/dist/esm/plugins/text-formatting/styles.js +0 -7
  81. package/dist/esm/plugins/text-formatting/types.js +0 -1
  82. package/dist/esm/plugins/text-formatting/ui/Toolbar/toolbar-messages.js +0 -88
  83. package/dist/types/plugins/text-formatting/styles.d.ts +0 -2
  84. package/dist/types/plugins/text-formatting/types.d.ts +0 -30
  85. package/dist/types/plugins/text-formatting/ui/Toolbar/toolbar-messages.d.ts +0 -87
  86. package/dist/types-ts4.5/plugins/text-formatting/styles.d.ts +0 -2
  87. package/dist/types-ts4.5/plugins/text-formatting/types.d.ts +0 -30
  88. package/dist/types-ts4.5/plugins/text-formatting/ui/Toolbar/toolbar-messages.d.ts +0 -87
@@ -8,16 +8,16 @@ import { compose, insideTable, isParagraph, isText, isLinkMark, insideTableCell,
8
8
  import { mapSlice } from '../../utils/slice';
9
9
  import { INPUT_METHOD } from '../analytics';
10
10
  import { GapCursorSelection, Side } from '../selection/gap-cursor-selection';
11
- import { linkifyContent } from '@atlaskit/editor-common/utils';
12
11
  import { runMacroAutoConvert } from '../macro';
13
12
  import { insertMediaAsMediaSingle } from '../media/utils/media-single';
14
- import { pluginKey as textFormattingPluginKey } from '../text-formatting/pm-plugins/main';
15
13
  import { addReplaceSelectedTableAnalytics, applyTextMarksToSlice, hasOnlyNodesOfType } from './util';
16
- import { isListItemNode, isListNode, canLinkBeCreatedInRange } from '@atlaskit/editor-common/utils';
14
+ import { linkifyContent, isListItemNode, isListNode, canLinkBeCreatedInRange } from '@atlaskit/editor-common/utils';
17
15
  import { insertSliceForLists } from './edge-cases';
18
16
  import { startTrackingPastedMacroPositions, stopTrackingPastedMacroPositions } from './commands';
19
17
  import { getPluginState as getPastePluginState } from './pm-plugins/plugin-factory';
20
18
  import { doesSelectionWhichStartsOrEndsInListContainEntireList } from '../../utils/lists';
19
+ import { anyMarkActive } from '@atlaskit/editor-common/mark';
20
+
21
21
  // remove text attribute from mention for copy/paste (GDPR)
22
22
  export function handleMention(slice, schema) {
23
23
  return mapSlice(slice, node => {
@@ -88,8 +88,7 @@ export function handlePasteIntoTaskOrDecisionOrPanel(slice, queueCardsFromChange
88
88
  }
89
89
  const filters = [linkifyContent(schema)];
90
90
  const selectionMarks = selection.$head.marks();
91
- const textFormattingState = textFormattingPluginKey.getState(state);
92
- if (selection instanceof TextSelection && Array.isArray(selectionMarks) && selectionMarks.length > 0 && hasOnlyNodesOfType(paragraph, text, emoji, mention, hardBreak)(slice) && (!codeMark.isInSet(selectionMarks) || textFormattingState !== null && textFormattingState !== void 0 && textFormattingState.codeActive) // for codeMarks let's make sure mark is active
91
+ if (selection instanceof TextSelection && Array.isArray(selectionMarks) && selectionMarks.length > 0 && hasOnlyNodesOfType(paragraph, text, emoji, mention, hardBreak)(slice) && (!codeMark.isInSet(selectionMarks) || anyMarkActive(state, codeMark)) // check if there is a code mark anywhere in the selection
93
92
  ) {
94
93
  filters.push(applyTextMarksToSlice(schema, selection.$head.marks()));
95
94
  }
@@ -386,11 +385,10 @@ export function handlePastePreservingMarks(slice, queueCardsFromChangedTr) {
386
385
  if (selectionMarks.length === 0) {
387
386
  return false;
388
387
  }
389
- const textFormattingState = textFormattingPluginKey.getState(state);
390
388
 
391
389
  // special case for codeMark: will preserve mark only if codeMark is currently active
392
390
  // won't preserve mark if cursor is on the edge on the mark (namely inactive)
393
- if (codeMark.isInSet(selectionMarks) && !(textFormattingState !== null && textFormattingState !== void 0 && textFormattingState.codeActive)) {
391
+ if (codeMark.isInSet(selectionMarks) && !anyMarkActive(state, codeMark)) {
394
392
  return false;
395
393
  }
396
394
  const isPlainTextSlice = slice.content.childCount === 1 && slice.content.firstChild.type === paragraph && slice.content.firstChild.content.childCount === 1 && slice.content.firstChild.firstChild.type === text;
@@ -0,0 +1,161 @@
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());
@@ -1,5 +1,5 @@
1
1
  import { Selection } from '@atlaskit/editor-prosemirror/state';
2
- import { applyMarkOnRange, toggleMark } from '@atlaskit/editor-common/mark';
2
+ import { applyMarkOnRange } from '@atlaskit/editor-common/mark';
3
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
5
  import { withAnalytics } from '@atlaskit/editor-common/editor-analytics';
@@ -107,164 +107,6 @@ export const moveLeft = () => {
107
107
  return false;
108
108
  };
109
109
  };
110
- export const toggleEm = () => {
111
- return (state, dispatch) => {
112
- const {
113
- em
114
- } = state.schema.marks;
115
- if (em) {
116
- return toggleMark(em)(state, dispatch);
117
- }
118
- return false;
119
- };
120
- };
121
- export const toggleEmWithAnalytics = editorAnalyticsAPI => ({
122
- inputMethod
123
- }) => withAnalytics(editorAnalyticsAPI, {
124
- action: ACTION.FORMATTED,
125
- actionSubject: ACTION_SUBJECT.TEXT,
126
- eventType: EVENT_TYPE.TRACK,
127
- actionSubjectId: ACTION_SUBJECT_ID.FORMAT_ITALIC,
128
- attributes: {
129
- inputMethod
130
- }
131
- })(toggleEm());
132
- export const toggleStrike = () => {
133
- return (state, dispatch) => {
134
- const {
135
- strike
136
- } = state.schema.marks;
137
- if (strike) {
138
- return toggleMark(strike)(state, dispatch);
139
- }
140
- return false;
141
- };
142
- };
143
- export const toggleStrikeWithAnalytics = editorAnalyticsAPI => ({
144
- inputMethod
145
- }) => withAnalytics(editorAnalyticsAPI, {
146
- action: ACTION.FORMATTED,
147
- actionSubject: ACTION_SUBJECT.TEXT,
148
- eventType: EVENT_TYPE.TRACK,
149
- actionSubjectId: ACTION_SUBJECT_ID.FORMAT_STRIKE,
150
- attributes: {
151
- inputMethod
152
- }
153
- })(toggleStrike());
154
- export const toggleStrong = () => {
155
- return (state, dispatch) => {
156
- const {
157
- strong
158
- } = state.schema.marks;
159
- if (strong) {
160
- return toggleMark(strong)(state, dispatch);
161
- }
162
- return false;
163
- };
164
- };
165
- export const toggleStrongWithAnalytics = editorAnalyticsAPI => ({
166
- inputMethod
167
- }) => withAnalytics(editorAnalyticsAPI, {
168
- action: ACTION.FORMATTED,
169
- actionSubject: ACTION_SUBJECT.TEXT,
170
- eventType: EVENT_TYPE.TRACK,
171
- actionSubjectId: ACTION_SUBJECT_ID.FORMAT_STRONG,
172
- attributes: {
173
- inputMethod
174
- }
175
- })(toggleStrong());
176
- export const toggleUnderline = () => {
177
- return (state, dispatch) => {
178
- const {
179
- underline
180
- } = state.schema.marks;
181
- if (underline) {
182
- return toggleMark(underline)(state, dispatch);
183
- }
184
- return false;
185
- };
186
- };
187
- export const toggleUnderlineWithAnalytics = editorAnalyticsAPI => ({
188
- inputMethod
189
- }) => withAnalytics(editorAnalyticsAPI, {
190
- action: ACTION.FORMATTED,
191
- actionSubject: ACTION_SUBJECT.TEXT,
192
- eventType: EVENT_TYPE.TRACK,
193
- actionSubjectId: ACTION_SUBJECT_ID.FORMAT_UNDERLINE,
194
- attributes: {
195
- inputMethod
196
- }
197
- })(toggleUnderline());
198
- export const toggleSuperscript = () => {
199
- return (state, dispatch) => {
200
- const {
201
- subsup
202
- } = state.schema.marks;
203
- if (subsup) {
204
- return toggleMark(subsup, {
205
- type: 'sup'
206
- })(state, dispatch);
207
- }
208
- return false;
209
- };
210
- };
211
- export const toggleSuperscriptWithAnalytics = editorAnalyticsAPI => ({
212
- inputMethod
213
- }) => withAnalytics(editorAnalyticsAPI, {
214
- action: ACTION.FORMATTED,
215
- actionSubject: ACTION_SUBJECT.TEXT,
216
- eventType: EVENT_TYPE.TRACK,
217
- actionSubjectId: ACTION_SUBJECT_ID.FORMAT_SUPER,
218
- attributes: {
219
- inputMethod
220
- }
221
- })(toggleSuperscript());
222
- export const toggleSubscript = () => {
223
- return (state, dispatch) => {
224
- const {
225
- subsup
226
- } = state.schema.marks;
227
- if (subsup) {
228
- return toggleMark(subsup, {
229
- type: 'sub'
230
- })(state, dispatch);
231
- }
232
- return false;
233
- };
234
- };
235
- export const toggleSubscriptWithAnalytics = editorAnalyticsAPI => ({
236
- inputMethod
237
- }) => withAnalytics(editorAnalyticsAPI, {
238
- action: ACTION.FORMATTED,
239
- actionSubject: ACTION_SUBJECT.TEXT,
240
- eventType: EVENT_TYPE.TRACK,
241
- actionSubjectId: ACTION_SUBJECT_ID.FORMAT_SUB,
242
- attributes: {
243
- inputMethod
244
- }
245
- })(toggleSubscript());
246
- export const toggleCode = () => {
247
- return (state, dispatch) => {
248
- const {
249
- code
250
- } = state.schema.marks;
251
- if (code) {
252
- return toggleMark(code)(state, dispatch);
253
- }
254
- return false;
255
- };
256
- };
257
- export const toggleCodeWithAnalytics = editorAnalyticsAPI => ({
258
- inputMethod
259
- }) => withAnalytics(editorAnalyticsAPI, {
260
- action: ACTION.FORMATTED,
261
- actionSubject: ACTION_SUBJECT.TEXT,
262
- eventType: EVENT_TYPE.TRACK,
263
- actionSubjectId: ACTION_SUBJECT_ID.FORMAT_CODE,
264
- attributes: {
265
- inputMethod
266
- }
267
- })(toggleCode());
268
110
  const createInlineCodeFromTextInput = (from, to, text) => {
269
111
  return (state, dispatch) => {
270
112
  if (state.selection.empty) {
@@ -9,6 +9,7 @@ import textFormattingInputRulePlugin from './pm-plugins/input-rule';
9
9
  import keymapPlugin from './pm-plugins/keymap';
10
10
  import textFormattingSmartInputRulePlugin from './pm-plugins/smart-input-rule';
11
11
  import Toolbar from './ui/Toolbar';
12
+ import { toggleSuperscript, toggleSuperscriptWithAnalytics, toggleSubscript, toggleSubscriptWithAnalytics, toggleStrike, toggleStrikeWithAnalytics, toggleCode, toggleCodeWithAnalytics, toggleUnderline, toggleUnderlineWithAnalytics, toggleEm, toggleEmWithAnalytics, toggleStrong, toggleStrongWithAnalytics } from './actions';
12
13
  const textFormatting = (options = {}, api) => ({
13
14
  name: 'textFormatting',
14
15
  marks() {
@@ -109,6 +110,22 @@ const textFormatting = (options = {}, api) => ({
109
110
  });
110
111
  }
111
112
  });
113
+ },
114
+ actions: {
115
+ toggleSuperscript,
116
+ toggleSuperscriptWithAnalytics,
117
+ toggleSubscript,
118
+ toggleSubscriptWithAnalytics,
119
+ toggleStrike,
120
+ toggleStrikeWithAnalytics,
121
+ toggleCode,
122
+ toggleCodeWithAnalytics,
123
+ toggleUnderline,
124
+ toggleUnderlineWithAnalytics,
125
+ toggleEm,
126
+ toggleEmWithAnalytics,
127
+ toggleStrong,
128
+ toggleStrongWithAnalytics
112
129
  }
113
130
  });
114
131
  export default textFormatting;
@@ -1,41 +1,41 @@
1
1
  import * as keymaps from '@atlaskit/editor-common/keymaps';
2
2
  import { keymap } from '@atlaskit/editor-prosemirror/keymap';
3
3
  import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
4
- import * as commands from '../commands/text-formatting';
4
+ import { toggleStrongWithAnalytics, toggleEmWithAnalytics, toggleCodeWithAnalytics, toggleStrikeWithAnalytics, toggleSubscriptWithAnalytics, toggleSuperscriptWithAnalytics, toggleUnderlineWithAnalytics } from '../actions';
5
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(editorAnalyticsAPI)({
8
+ keymaps.bindKeymapWithCommand(keymaps.toggleBold.common, 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(editorAnalyticsAPI)({
13
+ keymaps.bindKeymapWithCommand(keymaps.toggleItalic.common, 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(editorAnalyticsAPI)({
18
+ keymaps.bindKeymapWithCommand(keymaps.toggleCode.common, 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(editorAnalyticsAPI)({
23
+ keymaps.bindKeymapWithCommand(keymaps.toggleStrikethrough.common, 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(editorAnalyticsAPI)({
28
+ keymaps.bindKeymapWithCommand(keymaps.toggleSubscript.common, 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(editorAnalyticsAPI)({
33
+ keymaps.bindKeymapWithCommand(keymaps.toggleSuperscript.common, 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(editorAnalyticsAPI)({
38
+ keymaps.bindKeymapWithCommand(keymaps.toggleUnderline.common, toggleUnderlineWithAnalytics(editorAnalyticsAPI)({
39
39
  inputMethod: INPUT_METHOD.SHORTCUT
40
40
  }), list);
41
41
  }
@@ -6,7 +6,7 @@ import * as keymaps from '@atlaskit/editor-common/keymaps';
6
6
  import { shallowEqual } from '@atlaskit/editor-common/utils';
7
7
  import { createInlineCodeFromTextInputWithAnalytics } from '../commands/text-formatting';
8
8
  import * as commands from '../commands/text-formatting';
9
- import { anyMarkActive } from '../utils';
9
+ import { anyMarkActive } from '@atlaskit/editor-common/mark';
10
10
  import { pluginKey } from './plugin-key';
11
11
  export { pluginKey };
12
12
  const getTextFormattingState = (editorState, editorAnalyticsAPI) => {
@@ -2,7 +2,7 @@
2
2
  import { useCallback, useMemo } from 'react';
3
3
  import { jsx } from '@emotion/react';
4
4
  import { shortcutStyle } from '@atlaskit/editor-shared-styles/shortcut';
5
- import { toolbarMessages } from '../toolbar-messages';
5
+ import { toolbarMessages } from '@atlaskit/editor-common/messages';
6
6
  import { clearFormattingWithAnalytics } from '../../../commands/clear-formatting';
7
7
  import { pluginKey as clearFormattingPluginKey } from '../../../pm-plugins/clear-formatting';
8
8
  import { clearFormatting as clearFormattingKeymap, tooltip } from '@atlaskit/editor-common/keymaps';
@@ -4,8 +4,8 @@ import { jsx } from '@emotion/react';
4
4
  import BoldIcon from '@atlaskit/icon/glyph/editor/bold';
5
5
  import ItalicIcon from '@atlaskit/icon/glyph/editor/italic';
6
6
  import { shortcutStyle } from '@atlaskit/editor-shared-styles/shortcut';
7
- import { toolbarMessages } from '../toolbar-messages';
8
- import * as commands from '../../../commands/text-formatting';
7
+ import { toolbarMessages } from '@atlaskit/editor-common/messages';
8
+ import { toggleStrongWithAnalytics, toggleEmWithAnalytics, toggleCodeWithAnalytics, toggleStrikeWithAnalytics, toggleSubscriptWithAnalytics, toggleSuperscriptWithAnalytics, toggleUnderlineWithAnalytics } from '../../../actions';
9
9
  import { TOOLBAR_ACTION_SUBJECT_ID, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
10
10
  import { pluginKey as textFormattingPluginKey } from '../../../pm-plugins/plugin-key';
11
11
  import { toggleCode, toggleStrikethrough, toggleUnderline, tooltip, toggleBold, toggleItalic, toggleSubscript, toggleSuperscript, ToolTipContent, getAriaKeyshortcuts } from '@atlaskit/editor-common/keymaps';
@@ -16,7 +16,7 @@ const withToolbarInputMethod = func => func({
16
16
  const IconButtons = editorAnalyticsAPI => ({
17
17
  strong: {
18
18
  buttonId: TOOLBAR_ACTION_SUBJECT_ID.TEXT_FORMATTING_STRONG,
19
- command: withToolbarInputMethod(commands.toggleStrongWithAnalytics(editorAnalyticsAPI)),
19
+ command: withToolbarInputMethod(toggleStrongWithAnalytics(editorAnalyticsAPI)),
20
20
  message: toolbarMessages.bold,
21
21
  tooltipKeymap: toggleBold,
22
22
  component: () => jsx(BoldIcon, {
@@ -25,7 +25,7 @@ const IconButtons = editorAnalyticsAPI => ({
25
25
  },
26
26
  em: {
27
27
  buttonId: TOOLBAR_ACTION_SUBJECT_ID.TEXT_FORMATTING_ITALIC,
28
- command: withToolbarInputMethod(commands.toggleEmWithAnalytics(editorAnalyticsAPI)),
28
+ command: withToolbarInputMethod(toggleEmWithAnalytics(editorAnalyticsAPI)),
29
29
  message: toolbarMessages.italic,
30
30
  tooltipKeymap: toggleItalic,
31
31
  component: () => jsx(ItalicIcon, {
@@ -33,27 +33,27 @@ const IconButtons = editorAnalyticsAPI => ({
33
33
  })
34
34
  },
35
35
  underline: {
36
- command: withToolbarInputMethod(commands.toggleUnderlineWithAnalytics(editorAnalyticsAPI)),
36
+ command: withToolbarInputMethod(toggleUnderlineWithAnalytics(editorAnalyticsAPI)),
37
37
  message: toolbarMessages.underline,
38
38
  tooltipKeymap: toggleUnderline
39
39
  },
40
40
  strike: {
41
- command: withToolbarInputMethod(commands.toggleStrikeWithAnalytics(editorAnalyticsAPI)),
41
+ command: withToolbarInputMethod(toggleStrikeWithAnalytics(editorAnalyticsAPI)),
42
42
  message: toolbarMessages.strike,
43
43
  tooltipKeymap: toggleStrikethrough
44
44
  },
45
45
  code: {
46
- command: withToolbarInputMethod(commands.toggleCodeWithAnalytics(editorAnalyticsAPI)),
46
+ command: withToolbarInputMethod(toggleCodeWithAnalytics(editorAnalyticsAPI)),
47
47
  message: toolbarMessages.code,
48
48
  tooltipKeymap: toggleCode
49
49
  },
50
50
  subscript: {
51
- command: withToolbarInputMethod(commands.toggleSubscriptWithAnalytics(editorAnalyticsAPI)),
51
+ command: withToolbarInputMethod(toggleSubscriptWithAnalytics(editorAnalyticsAPI)),
52
52
  message: toolbarMessages.subscript,
53
53
  tooltipKeymap: toggleSubscript
54
54
  },
55
55
  superscript: {
56
- command: withToolbarInputMethod(commands.toggleSuperscriptWithAnalytics(editorAnalyticsAPI)),
56
+ command: withToolbarInputMethod(toggleSuperscriptWithAnalytics(editorAnalyticsAPI)),
57
57
  message: toolbarMessages.superscript,
58
58
  tooltipKeymap: toggleSuperscript
59
59
  }
@@ -9,7 +9,7 @@ import { useResponsiveToolbarButtons, useResponsiveIconTypeMenu } from './hooks/
9
9
  import { SingleToolbarButtons } from './single-toolbar-buttons';
10
10
  import { MoreButton } from './more-button';
11
11
  import { FormattingTextDropdownMenu } from './dropdown-menu';
12
- import { toolbarMessages } from './toolbar-messages';
12
+ import { toolbarMessages } from '@atlaskit/editor-common/messages';
13
13
  import { compareItemsArrays, isArrayContainsContent } from '../../utils';
14
14
  import { Announcer } from '@atlaskit/editor-common/ui';
15
15
  import { usePreviousState } from '@atlaskit/editor-common/hooks';
@@ -1,4 +1,4 @@
1
- import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
1
+ import { anyMarkActive } from '@atlaskit/editor-common/mark';
2
2
  import { FORMATTING_MARK_TYPES, FORMATTING_NODE_TYPES } from './commands/clear-formatting';
3
3
  export const hasCode = (state, pos) => {
4
4
  const {
@@ -31,34 +31,6 @@ export const markActive = (state, mark) => {
31
31
  });
32
32
  return found;
33
33
  };
34
-
35
- /**
36
- * Determine if a mark of a specific type exists anywhere in the selection.
37
- */
38
- export const anyMarkActive = (state, markType) => {
39
- const {
40
- $from,
41
- from,
42
- to,
43
- empty
44
- } = state.selection;
45
- if (empty) {
46
- return !!markType.isInSet(state.storedMarks || $from.marks());
47
- }
48
- let rangeHasMark = false;
49
- if (state.selection instanceof CellSelection) {
50
- state.selection.forEachCell((cell, cellPos) => {
51
- const from = cellPos;
52
- const to = cellPos + cell.nodeSize;
53
- if (!rangeHasMark) {
54
- rangeHasMark = state.doc.rangeHasMark(from, to, markType);
55
- }
56
- });
57
- } else {
58
- rangeHasMark = state.doc.rangeHasMark(from, to, markType);
59
- }
60
- return rangeHasMark;
61
- };
62
34
  const blockStylingIsPresent = state => {
63
35
  let {
64
36
  from,
@@ -18,7 +18,6 @@ import { panelStyles } from '../../plugins/panel/styles';
18
18
  import { fakeCursorStyles } from '../../plugins/fake-text-cursor/styles';
19
19
  import { mentionsStyles } from '../../plugins/mentions/styles';
20
20
  import { emojiStyles } from '../../plugins/emoji/styles';
21
- import { textFormattingStyles } from '../../plugins/text-formatting/styles';
22
21
  import { placeholderTextStyles } from '../../plugins/placeholder-text/styles';
23
22
  import { extensionStyles } from '../../plugins/extension/ui/styles';
24
23
  import { expandStyles } from '../../plugins/expand/ui/styles';
@@ -28,7 +27,7 @@ import { taskDecisionStyles } from '../../plugins/tasks-and-decisions/styles';
28
27
  import { statusStyles } from '../../plugins/status/styles';
29
28
  import { dateStyles } from '../../plugins/date/styles';
30
29
  import { InlineNodeViewSharedStyles } from '../../nodeviews/getInlineNodeViewProducer.styles';
31
- import { linkSharedStyle } from '@atlaskit/editor-common/styles';
30
+ import { linkSharedStyle, codeMarkSharedStyles } from '@atlaskit/editor-common/styles';
32
31
  export const linkStyles = css`
33
32
  .ProseMirror {
34
33
  ${linkSharedStyle}
@@ -74,7 +73,7 @@ const contentStyles = props => css`
74
73
  ${codeBlockStyles(props)}
75
74
 
76
75
  ${blocktypeStyles(props)}
77
- ${textFormattingStyles(props)}
76
+ ${codeMarkSharedStyles(props)}
78
77
  ${textColorStyles}
79
78
  ${listsStyles}
80
79
  ${ruleStyles(props)}
@@ -1,5 +1,5 @@
1
1
  export const name = "@atlaskit/editor-core";
2
- export const version = "187.10.8";
2
+ export const version = "187.11.0";
3
3
  export const nextMajorVersion = () => {
4
4
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
5
5
  };
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-core",
3
- "version": "187.10.8",
3
+ "version": "187.11.0",
4
4
  "sideEffects": false
5
5
  }
package/dist/esm/index.js CHANGED
@@ -17,13 +17,11 @@ export { AnnotationUpdateEmitter } from './plugins/annotation';
17
17
  // Used in mobile bridge
18
18
  export { stateKey as mediaPluginKey } from './plugins/media/pm-plugins/main';
19
19
  export { mentionPluginKey } from './plugins/mentions';
20
- export { pluginKey as textFormattingStateKey } from './plugins/text-formatting/pm-plugins/main';
21
20
  export { textColorPluginKey } from './plugins/text-color';
22
21
  export { changeColor } from './plugins/text-color/commands/change-color';
23
22
  export { insertHorizontalRule } from './plugins/rule/commands';
24
23
  export { blockPluginStateKey } from './plugins';
25
24
  export { pluginKey as listStateKey } from './plugins/list/pm-plugins/main';
26
- export { toggleSuperscript, toggleSuperscriptWithAnalytics, toggleSubscript, toggleSubscriptWithAnalytics, toggleStrike, toggleStrikeWithAnalytics, toggleCode, toggleCodeWithAnalytics, toggleUnderline, toggleUnderlineWithAnalytics, toggleEm, toggleEmWithAnalytics, toggleStrong, toggleStrongWithAnalytics } from './plugins/text-formatting/commands/text-formatting';
27
25
  export { subscribeToToolbarAndPickerUpdates } from './plugins/view-update-subscription/subscribe/toolbarAndPickerUpdates';
28
26
  export { subscribeTypeAheadUpdates } from './plugins/view-update-subscription/subscribe/type-ahead-updates';
29
27
  export { insertBlockType, insertBlockTypesWithAnalytics, setBlockType, setBlockTypeWithAnalytics } from './plugins/block-type/commands';
@@ -19,7 +19,7 @@ import AkModalDialog, { ModalTransition, useModal } from '@atlaskit/modal-dialog
19
19
  import { header, footer, contentWrapper, line, content, row, codeSm, codeMd, codeLg, title, column, dialogHeader } from './styles';
20
20
  import * as keymaps from '../../../keymaps';
21
21
  import ToolbarButton from '../../../ui/ToolbarButton';
22
- import { toolbarMessages } from '../../text-formatting/ui/Toolbar/toolbar-messages';
22
+ import { toolbarMessages } from '@atlaskit/editor-common/messages';
23
23
  import { messages as listMessages } from '../../list/messages';
24
24
  import { messages as insertBlockMessages } from '../../insert-block/ui/ToolbarInsertBlock/messages';
25
25
  import { messages as blockTypeMessages } from '../../block-type/messages';