@atlaskit/editor-core 187.10.6 → 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 (105) hide show
  1. package/CHANGELOG.md +16 -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/media/nodeviews/mediaNodeUpdater.js +5 -5
  5. package/dist/cjs/plugins/media/nodeviews/mediaNodeView/index.js +3 -3
  6. package/dist/cjs/plugins/media/nodeviews/mediaSingle.js +15 -6
  7. package/dist/cjs/plugins/media/ui/ResizableMediaSingle/ResizableMediaSingleNext.js +18 -16
  8. package/dist/cjs/plugins/media/utils/media-single.js +5 -9
  9. package/dist/cjs/plugins/paste/handlers.js +4 -6
  10. package/dist/cjs/plugins/text-formatting/actions.js +188 -0
  11. package/dist/cjs/plugins/text-formatting/commands/text-formatting.js +1 -180
  12. package/dist/cjs/plugins/text-formatting/index.js +17 -0
  13. package/dist/cjs/plugins/text-formatting/pm-plugins/keymap.js +8 -8
  14. package/dist/cjs/plugins/text-formatting/pm-plugins/main.js +8 -8
  15. package/dist/cjs/plugins/text-formatting/ui/Toolbar/hooks/clear-formatting-icon.js +2 -2
  16. package/dist/cjs/plugins/text-formatting/ui/Toolbar/hooks/formatting-icons.js +16 -16
  17. package/dist/cjs/plugins/text-formatting/ui/Toolbar/index.js +8 -8
  18. package/dist/cjs/plugins/text-formatting/utils.js +8 -36
  19. package/dist/cjs/ui/ContentStyles/index.js +8 -9
  20. package/dist/cjs/version-wrapper.js +1 -1
  21. package/dist/cjs/version.json +1 -1
  22. package/dist/es2019/index.js +0 -2
  23. package/dist/es2019/plugins/help-dialog/ui/index.js +1 -1
  24. package/dist/es2019/plugins/media/nodeviews/mediaNodeUpdater.js +1 -1
  25. package/dist/es2019/plugins/media/nodeviews/mediaNodeView/index.js +1 -1
  26. package/dist/es2019/plugins/media/nodeviews/mediaSingle.js +13 -4
  27. package/dist/es2019/plugins/media/ui/ResizableMediaSingle/ResizableMediaSingleNext.js +11 -10
  28. package/dist/es2019/plugins/media/utils/media-single.js +6 -7
  29. package/dist/es2019/plugins/paste/handlers.js +5 -7
  30. package/dist/es2019/plugins/text-formatting/actions.js +161 -0
  31. package/dist/es2019/plugins/text-formatting/commands/text-formatting.js +1 -159
  32. package/dist/es2019/plugins/text-formatting/index.js +17 -0
  33. package/dist/es2019/plugins/text-formatting/pm-plugins/keymap.js +8 -8
  34. package/dist/es2019/plugins/text-formatting/pm-plugins/main.js +1 -1
  35. package/dist/es2019/plugins/text-formatting/ui/Toolbar/hooks/clear-formatting-icon.js +1 -1
  36. package/dist/es2019/plugins/text-formatting/ui/Toolbar/hooks/formatting-icons.js +9 -9
  37. package/dist/es2019/plugins/text-formatting/ui/Toolbar/index.js +1 -1
  38. package/dist/es2019/plugins/text-formatting/utils.js +1 -29
  39. package/dist/es2019/ui/ContentStyles/index.js +2 -3
  40. package/dist/es2019/version-wrapper.js +1 -1
  41. package/dist/es2019/version.json +1 -1
  42. package/dist/esm/index.js +0 -2
  43. package/dist/esm/plugins/help-dialog/ui/index.js +1 -1
  44. package/dist/esm/plugins/media/nodeviews/mediaNodeUpdater.js +1 -1
  45. package/dist/esm/plugins/media/nodeviews/mediaNodeView/index.js +1 -1
  46. package/dist/esm/plugins/media/nodeviews/mediaSingle.js +13 -4
  47. package/dist/esm/plugins/media/ui/ResizableMediaSingle/ResizableMediaSingleNext.js +21 -19
  48. package/dist/esm/plugins/media/utils/media-single.js +6 -10
  49. package/dist/esm/plugins/paste/handlers.js +5 -7
  50. package/dist/esm/plugins/text-formatting/actions.js +168 -0
  51. package/dist/esm/plugins/text-formatting/commands/text-formatting.js +1 -166
  52. package/dist/esm/plugins/text-formatting/index.js +17 -0
  53. package/dist/esm/plugins/text-formatting/pm-plugins/keymap.js +8 -8
  54. package/dist/esm/plugins/text-formatting/pm-plugins/main.js +1 -1
  55. package/dist/esm/plugins/text-formatting/ui/Toolbar/hooks/clear-formatting-icon.js +1 -1
  56. package/dist/esm/plugins/text-formatting/ui/Toolbar/hooks/formatting-icons.js +9 -9
  57. package/dist/esm/plugins/text-formatting/ui/Toolbar/index.js +1 -1
  58. package/dist/esm/plugins/text-formatting/utils.js +6 -33
  59. package/dist/esm/ui/ContentStyles/index.js +2 -3
  60. package/dist/esm/version-wrapper.js +1 -1
  61. package/dist/esm/version.json +1 -1
  62. package/dist/types/index.d.ts +6 -4
  63. package/dist/types/labs/next/presets/default.d.ts +78 -15
  64. package/dist/types/plugins/media/nodeviews/mediaNodeUpdater.d.ts +1 -2
  65. package/dist/types/plugins/media/ui/ResizableMediaSingle/guidelines.d.ts +1 -1
  66. package/dist/types/plugins/paste/handlers.d.ts +1 -2
  67. package/dist/types/plugins/text-formatting/actions.d.ts +20 -0
  68. package/dist/types/plugins/text-formatting/commands/text-formatting.d.ts +0 -31
  69. package/dist/types/plugins/text-formatting/index.d.ts +18 -2
  70. package/dist/types/plugins/text-formatting/pm-plugins/main.d.ts +1 -2
  71. package/dist/types/plugins/text-formatting/pm-plugins/plugin-key.d.ts +1 -1
  72. package/dist/types/plugins/text-formatting/utils.d.ts +1 -5
  73. package/dist/types/types/editor-props.d.ts +1 -2
  74. package/dist/types/ui/ContentStyles/index.d.ts +1 -1
  75. package/dist/types-ts4.5/index.d.ts +6 -4
  76. package/dist/types-ts4.5/labs/next/presets/default.d.ts +78 -15
  77. package/dist/types-ts4.5/plugins/media/nodeviews/mediaNodeUpdater.d.ts +1 -2
  78. package/dist/types-ts4.5/plugins/media/ui/ResizableMediaSingle/guidelines.d.ts +1 -1
  79. package/dist/types-ts4.5/plugins/paste/handlers.d.ts +1 -2
  80. package/dist/types-ts4.5/plugins/text-formatting/actions.d.ts +20 -0
  81. package/dist/types-ts4.5/plugins/text-formatting/commands/text-formatting.d.ts +0 -31
  82. package/dist/types-ts4.5/plugins/text-formatting/index.d.ts +18 -2
  83. package/dist/types-ts4.5/plugins/text-formatting/pm-plugins/main.d.ts +1 -2
  84. package/dist/types-ts4.5/plugins/text-formatting/pm-plugins/plugin-key.d.ts +1 -1
  85. package/dist/types-ts4.5/plugins/text-formatting/utils.d.ts +1 -5
  86. package/dist/types-ts4.5/types/editor-props.d.ts +1 -2
  87. package/dist/types-ts4.5/ui/ContentStyles/index.d.ts +1 -1
  88. package/package.json +3 -3
  89. package/report.api.md +31 -145
  90. package/tmp/api-report-tmp.d.ts +30 -118
  91. package/dist/cjs/plugins/text-formatting/styles.js +0 -15
  92. package/dist/cjs/plugins/text-formatting/types.js +0 -5
  93. package/dist/cjs/plugins/text-formatting/ui/Toolbar/toolbar-messages.js +0 -95
  94. package/dist/es2019/plugins/text-formatting/styles.js +0 -5
  95. package/dist/es2019/plugins/text-formatting/types.js +0 -1
  96. package/dist/es2019/plugins/text-formatting/ui/Toolbar/toolbar-messages.js +0 -88
  97. package/dist/esm/plugins/text-formatting/styles.js +0 -7
  98. package/dist/esm/plugins/text-formatting/types.js +0 -1
  99. package/dist/esm/plugins/text-formatting/ui/Toolbar/toolbar-messages.js +0 -88
  100. package/dist/types/plugins/text-formatting/styles.d.ts +0 -2
  101. package/dist/types/plugins/text-formatting/types.d.ts +0 -30
  102. package/dist/types/plugins/text-formatting/ui/Toolbar/toolbar-messages.d.ts +0 -87
  103. package/dist/types-ts4.5/plugins/text-formatting/styles.d.ts +0 -2
  104. package/dist/types-ts4.5/plugins/text-formatting/types.d.ts +0 -30
  105. package/dist/types-ts4.5/plugins/text-formatting/ui/Toolbar/toolbar-messages.d.ts +0 -87
@@ -23,7 +23,7 @@ var _responsiveToolbarButtons = require("./hooks/responsive-toolbar-buttons");
23
23
  var _singleToolbarButtons = require("./single-toolbar-buttons");
24
24
  var _moreButton = require("./more-button");
25
25
  var _dropdownMenu = require("./dropdown-menu");
26
- var _toolbarMessages = require("./toolbar-messages");
26
+ var _messages = require("@atlaskit/editor-common/messages");
27
27
  var _utils = require("../../utils");
28
28
  var _ui = require("@atlaskit/editor-common/ui");
29
29
  var _hooks = require("@atlaskit/editor-common/hooks");
@@ -76,9 +76,9 @@ var ToolbarFormatting = function ToolbarFormatting(_ref) {
76
76
  }),
77
77
  dropdownItems = _useResponsiveToolbar.dropdownItems,
78
78
  singleItems = _useResponsiveToolbar.singleItems;
79
- var clearFormattingStatus = intl.formatMessage(_toolbarMessages.toolbarMessages.textFormattingOff);
80
- var superscriptOffSubscriptOnStatus = intl.formatMessage(_toolbarMessages.toolbarMessages.superscriptOffSubscriptOn);
81
- var subscriptOffSuperscriptOnStatus = intl.formatMessage(_toolbarMessages.toolbarMessages.subscriptOffSuperscriptOn);
79
+ var clearFormattingStatus = intl.formatMessage(_messages.toolbarMessages.textFormattingOff);
80
+ var superscriptOffSubscriptOnStatus = intl.formatMessage(_messages.toolbarMessages.superscriptOffSubscriptOn);
81
+ var subscriptOffSuperscriptOnStatus = intl.formatMessage(_messages.toolbarMessages.subscriptOffSuperscriptOn);
82
82
  var activeItems = [].concat((0, _toConsumableArray2.default)(dropdownItems), (0, _toConsumableArray2.default)(singleItems)).filter(function (item) {
83
83
  return item.isActive;
84
84
  });
@@ -89,18 +89,18 @@ var ToolbarFormatting = function ToolbarFormatting(_ref) {
89
89
  var screenReaderMessage = '';
90
90
  if (prevActiveItems && activeItems.length > prevActiveItems.length) {
91
91
  comparedItems = (0, _utils.compareItemsArrays)(activeItems, prevActiveItems);
92
- screenReaderMessage = intl.formatMessage(_toolbarMessages.toolbarMessages.on, {
92
+ screenReaderMessage = intl.formatMessage(_messages.toolbarMessages.on, {
93
93
  formattingType: comparedItems[0].content
94
94
  });
95
95
  } else {
96
96
  comparedItems = (0, _utils.compareItemsArrays)(prevActiveItems, activeItems);
97
97
  if (comparedItems && comparedItems.length) {
98
98
  var _activeItems$;
99
- screenReaderMessage = intl.formatMessage(_toolbarMessages.toolbarMessages.off, {
99
+ screenReaderMessage = intl.formatMessage(_messages.toolbarMessages.off, {
100
100
  formattingType: comparedItems[0].content
101
101
  });
102
102
  if (((_activeItems$ = activeItems[0]) === null || _activeItems$ === void 0 ? void 0 : _activeItems$.content) === 'Code') {
103
- screenReaderMessage = intl.formatMessage(_toolbarMessages.toolbarMessages.codeOn, {
103
+ screenReaderMessage = intl.formatMessage(_messages.toolbarMessages.codeOn, {
104
104
  textFormattingOff: (prevActiveItems === null || prevActiveItems === void 0 ? void 0 : prevActiveItems.length) > 1 ? clearFormattingStatus : screenReaderMessage
105
105
  });
106
106
  }
@@ -123,7 +123,7 @@ var ToolbarFormatting = function ToolbarFormatting(_ref) {
123
123
  }
124
124
  return [].concat((0, _toConsumableArray2.default)(dropdownItems), [clearIcon]);
125
125
  }, [clearIcon, dropdownItems]);
126
- var moreFormattingButtonLabel = intl.formatMessage(_toolbarMessages.toolbarMessages.moreFormatting);
126
+ var moreFormattingButtonLabel = intl.formatMessage(_messages.toolbarMessages.moreFormatting);
127
127
  (0, _react.useEffect)(function () {
128
128
  if (screenReaderMessage) {
129
129
  setMessage(screenReaderMessage);
@@ -3,8 +3,8 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.markActive = exports.isArrayContainsContent = exports.hasCode = exports.compareItemsArrays = exports.checkFormattingIsPresent = exports.anyMarkActive = void 0;
7
- var _cellSelection = require("@atlaskit/editor-tables/cell-selection");
6
+ exports.markActive = exports.isArrayContainsContent = exports.hasCode = exports.compareItemsArrays = exports.checkFormattingIsPresent = void 0;
7
+ var _mark = require("@atlaskit/editor-common/mark");
8
8
  var _clearFormatting = require("./commands/clear-formatting");
9
9
  var hasCode = function hasCode(state, pos) {
10
10
  var code = state.schema.marks.code;
@@ -37,39 +37,11 @@ var markActive = function markActive(state, mark) {
37
37
  });
38
38
  return found;
39
39
  };
40
-
41
- /**
42
- * Determine if a mark of a specific type exists anywhere in the selection.
43
- */
44
40
  exports.markActive = markActive;
45
- var anyMarkActive = function anyMarkActive(state, markType) {
41
+ var blockStylingIsPresent = function blockStylingIsPresent(state) {
46
42
  var _state$selection2 = state.selection,
47
- $from = _state$selection2.$from,
48
43
  from = _state$selection2.from,
49
- to = _state$selection2.to,
50
- empty = _state$selection2.empty;
51
- if (empty) {
52
- return !!markType.isInSet(state.storedMarks || $from.marks());
53
- }
54
- var rangeHasMark = false;
55
- if (state.selection instanceof _cellSelection.CellSelection) {
56
- state.selection.forEachCell(function (cell, cellPos) {
57
- var from = cellPos;
58
- var to = cellPos + cell.nodeSize;
59
- if (!rangeHasMark) {
60
- rangeHasMark = state.doc.rangeHasMark(from, to, markType);
61
- }
62
- });
63
- } else {
64
- rangeHasMark = state.doc.rangeHasMark(from, to, markType);
65
- }
66
- return rangeHasMark;
67
- };
68
- exports.anyMarkActive = anyMarkActive;
69
- var blockStylingIsPresent = function blockStylingIsPresent(state) {
70
- var _state$selection3 = state.selection,
71
- from = _state$selection3.from,
72
- to = _state$selection3.to;
44
+ to = _state$selection2.to;
73
45
  var isBlockStyling = false;
74
46
  state.doc.nodesBetween(from, to, function (node) {
75
47
  if (_clearFormatting.FORMATTING_NODE_TYPES.indexOf(node.type.name) !== -1) {
@@ -83,14 +55,14 @@ var blockStylingIsPresent = function blockStylingIsPresent(state) {
83
55
  var marksArePresent = function marksArePresent(state) {
84
56
  var activeMarkTypes = _clearFormatting.FORMATTING_MARK_TYPES.filter(function (mark) {
85
57
  if (!!state.schema.marks[mark]) {
86
- var _state$selection4 = state.selection,
87
- $from = _state$selection4.$from,
88
- empty = _state$selection4.empty;
58
+ var _state$selection3 = state.selection,
59
+ $from = _state$selection3.$from,
60
+ empty = _state$selection3.empty;
89
61
  var marks = state.schema.marks;
90
62
  if (empty) {
91
63
  return !!marks[mark].isInSet(state.storedMarks || $from.marks());
92
64
  }
93
- return anyMarkActive(state, marks[mark]);
65
+ return (0, _mark.anyMarkActive)(state, marks[mark]);
94
66
  }
95
67
  return false;
96
68
  });
@@ -26,15 +26,14 @@ var _styles12 = require("../../plugins/panel/styles");
26
26
  var _styles13 = require("../../plugins/fake-text-cursor/styles");
27
27
  var _styles14 = require("../../plugins/mentions/styles");
28
28
  var _styles15 = require("../../plugins/emoji/styles");
29
- var _styles16 = require("../../plugins/text-formatting/styles");
30
- var _styles17 = require("../../plugins/placeholder-text/styles");
31
- var _styles18 = require("../../plugins/extension/ui/styles");
32
- var _styles19 = require("../../plugins/expand/ui/styles");
29
+ var _styles16 = require("../../plugins/placeholder-text/styles");
30
+ var _styles17 = require("../../plugins/extension/ui/styles");
31
+ var _styles18 = require("../../plugins/expand/ui/styles");
33
32
  var _style = require("../../plugins/media/pm-plugins/alt-text/style");
34
- var _styles20 = require("../../plugins/find-replace/styles");
35
- var _styles21 = require("../../plugins/tasks-and-decisions/styles");
36
- var _styles22 = require("../../plugins/status/styles");
37
- var _styles23 = require("../../plugins/date/styles");
33
+ var _styles19 = require("../../plugins/find-replace/styles");
34
+ var _styles20 = require("../../plugins/tasks-and-decisions/styles");
35
+ var _styles21 = require("../../plugins/status/styles");
36
+ var _styles22 = require("../../plugins/date/styles");
38
37
  var _getInlineNodeViewProducer = require("../../nodeviews/getInlineNodeViewProducer.styles");
39
38
  var _templateObject, _templateObject2;
40
39
  /** @jsx jsx */
@@ -45,7 +44,7 @@ exports.linkStyles = linkStyles;
45
44
  var contentStyles = function contentStyles(props) {
46
45
  return (0, _react2.css)(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2.default)(["\n .ProseMirror {\n outline: none;\n font-size: ", "px;\n ", ";\n ", ";\n ", ";\n ", ";\n ", ";\n ", ";\n }\n\n .ProseMirror[contenteditable='false'] .taskItemView-content-wrap {\n pointer-events: none;\n opacity: 0.7;\n }\n\n .ProseMirror-hideselection *::selection {\n background: transparent;\n }\n\n .ProseMirror-hideselection *::-moz-selection {\n background: transparent;\n }\n\n .ProseMirror-selectednode {\n outline: none;\n }\n\n .ProseMirror-selectednode:empty {\n outline: 2px solid ", ";\n }\n\n ", "\n ", "\n ", "\n\n ", "\n ", "\n ", "\n ", "\n ", "\n ", "\n ", "\n ", "\n ", ";\n ", "\n ", "\n ", "\n ", "\n ", "\n ", "\n ", "\n ", "\n ", "\n ", "\n ", "\n ", "\n ", "\n ", "\n ", "\n ", "\n ", "\n ", "\n ", "\n ", "\n ", "\n ", "\n\n .panelView-content-wrap {\n box-sizing: border-box;\n }\n\n .mediaGroupView-content-wrap ul {\n padding: 0;\n }\n\n /** Needed to override any cleared floats, e.g. image wrapping */\n\n div.fabric-editor-block-mark[class^='fabric-editor-align'] {\n clear: none !important;\n }\n\n .fabric-editor-align-end {\n text-align: right;\n }\n\n .fabric-editor-align-start {\n text-align: left;\n }\n\n .fabric-editor-align-center {\n text-align: center;\n }\n\n .pm-table-header-content-wrap :not(.fabric-editor-alignment),\n .pm-table-header-content-wrap\n :not(p, .fabric-editor-block-mark)\n + div.fabric-editor-block-mark,\n .pm-table-cell-content-wrap\n :not(p, .fabric-editor-block-mark)\n + div.fabric-editor-block-mark {\n p:first-of-type {\n margin-top: 0;\n }\n }\n\n .hyperlink-floating-toolbar,\n .", " {\n padding: 0;\n }\n\n /* Link icon in the Atlaskit package\n is bigger than the others\n */\n .hyperlink-open-link {\n svg {\n max-width: 18px;\n }\n &[href] {\n padding: 0 4px;\n }\n }\n"])), (0, _editorSharedStyles.editorFontSize)({
47
46
  theme: props.theme
48
- }), _styles.whitespaceSharedStyles, _styles.paragraphSharedStyles, _styles.listsSharedStyles, _styles.indentationSharedStyles, _styles.shadowSharedStyle, _getInlineNodeViewProducer.InlineNodeViewSharedStyles, "var(--ds-border-focused, #8cf)", _styles17.placeholderTextStyles, _styles5.placeholderStyles, (0, _styles7.codeBlockStyles)(props), (0, _styles6.blocktypeStyles)(props), (0, _styles16.textFormattingStyles)(props), _styles.textColorStyles, _styles8.listsStyles, (0, _styles9.ruleStyles)(props), _styles10.mediaStyles, (0, _styles11.layoutStyles)(props), _styles3.telepointerStyle, _styles4.gapCursorStyles, (0, _commonStyles.tableStyles)(props), (0, _styles12.panelStyles)(props), _styles13.fakeCursorStyles, _styles14.mentionsStyles, _styles15.emojiStyles, _styles.tasksAndDecisionsStyles, _styles.gridStyles, linkStyles, _styles.blockMarksSharedStyles, _styles.dateSharedStyle, _styles18.extensionStyles, (0, _styles19.expandStyles)(props), _styles20.findReplaceStyles, _styles21.taskDecisionStyles, _styles22.statusStyles, (0, _styles.annotationSharedStyles)(props), _styles.smartCardStyles, _styles.smartCardSharedStyles, _styles23.dateStyles, _styles.embedCardStyles, _styles2.unsupportedStyles, _styles.resizerStyles, _style.ClassNames.FLOATING_TOOLBAR_COMPONENT);
47
+ }), _styles.whitespaceSharedStyles, _styles.paragraphSharedStyles, _styles.listsSharedStyles, _styles.indentationSharedStyles, _styles.shadowSharedStyle, _getInlineNodeViewProducer.InlineNodeViewSharedStyles, "var(--ds-border-focused, #8cf)", _styles16.placeholderTextStyles, _styles5.placeholderStyles, (0, _styles7.codeBlockStyles)(props), (0, _styles6.blocktypeStyles)(props), (0, _styles.codeMarkSharedStyles)(props), _styles.textColorStyles, _styles8.listsStyles, (0, _styles9.ruleStyles)(props), _styles10.mediaStyles, (0, _styles11.layoutStyles)(props), _styles3.telepointerStyle, _styles4.gapCursorStyles, (0, _commonStyles.tableStyles)(props), (0, _styles12.panelStyles)(props), _styles13.fakeCursorStyles, _styles14.mentionsStyles, _styles15.emojiStyles, _styles.tasksAndDecisionsStyles, _styles.gridStyles, linkStyles, _styles.blockMarksSharedStyles, _styles.dateSharedStyle, _styles17.extensionStyles, (0, _styles18.expandStyles)(props), _styles19.findReplaceStyles, _styles20.taskDecisionStyles, _styles21.statusStyles, (0, _styles.annotationSharedStyles)(props), _styles.smartCardStyles, _styles.smartCardSharedStyles, _styles22.dateStyles, _styles.embedCardStyles, _styles2.unsupportedStyles, _styles.resizerStyles, _style.ClassNames.FLOATING_TOOLBAR_COMPONENT);
49
48
  };
50
49
  var createEditorContentStyle = function createEditorContentStyle(styles) {
51
50
  return /*#__PURE__*/_react.default.forwardRef(function (props, ref) {
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.version = exports.nextMajorVersion = exports.name = void 0;
7
7
  var name = "@atlaskit/editor-core";
8
8
  exports.name = name;
9
- var version = "187.10.6";
9
+ var version = "187.11.0";
10
10
  exports.version = version;
11
11
  var nextMajorVersion = function nextMajorVersion() {
12
12
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-core",
3
- "version": "187.10.6",
3
+ "version": "187.11.0",
4
4
  "sideEffects": false
5
5
  }
@@ -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';
@@ -10,7 +10,7 @@ import AkModalDialog, { ModalTransition, useModal } from '@atlaskit/modal-dialog
10
10
  import { header, footer, contentWrapper, line, content, row, codeSm, codeMd, codeLg, title, column, dialogHeader } from './styles';
11
11
  import * as keymaps from '../../../keymaps';
12
12
  import ToolbarButton from '../../../ui/ToolbarButton';
13
- import { toolbarMessages } from '../../text-formatting/ui/Toolbar/toolbar-messages';
13
+ import { toolbarMessages } from '@atlaskit/editor-common/messages';
14
14
  import { messages as listMessages } from '../../list/messages';
15
15
  import { messages as insertBlockMessages } from '../../insert-block/ui/ToolbarInsertBlock/messages';
16
16
  import { messages as blockTypeMessages } from '../../block-type/messages';
@@ -1,6 +1,6 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  import uuidV4 from 'uuid/v4';
3
- import { DEFAULT_IMAGE_HEIGHT, DEFAULT_IMAGE_WIDTH } from '@atlaskit/editor-common/ui';
3
+ import { DEFAULT_IMAGE_HEIGHT, DEFAULT_IMAGE_WIDTH } from '@atlaskit/editor-common/media-single';
4
4
  import { getMediaClient, isMediaBlobUrl, getAttrsFromUrl, isImageRepresentationReady } from '@atlaskit/media-client';
5
5
  import { ACTION, ACTION_SUBJECT, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
6
6
  import { replaceExternalMedia, updateAllMediaSingleNodesAttrs, updateCurrentMediaNodeAttrs, updateMediaSingleNodeAttrs } from '../commands/helpers';
@@ -1,6 +1,6 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  import { WithProviders } from '@atlaskit/editor-common/provider-factory';
3
- import { DEFAULT_IMAGE_HEIGHT, DEFAULT_IMAGE_WIDTH } from '@atlaskit/editor-common/ui';
3
+ import { DEFAULT_IMAGE_HEIGHT, DEFAULT_IMAGE_WIDTH } from '@atlaskit/editor-common/media-single';
4
4
  import React from 'react';
5
5
  import { SelectionBasedNodeView } from '@atlaskit/editor-common/selection-based-node-view';
6
6
  import MediaNode from './media';
@@ -3,7 +3,7 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
3
  import { jsx } from '@emotion/react';
4
4
  import React, { Component } from 'react';
5
5
  import { WithProviders } from '@atlaskit/editor-common/provider-factory';
6
- import { MediaSingle, DEFAULT_IMAGE_HEIGHT, DEFAULT_IMAGE_WIDTH } from '@atlaskit/editor-common/ui';
6
+ import { MediaSingle } from '@atlaskit/editor-common/ui';
7
7
  import { browser, floatingLayouts, isRichMediaInsideOfBlockNode } from '@atlaskit/editor-common/utils';
8
8
  import { isNodeSelectedOrInRange } from '../../../utils/nodes';
9
9
  import { setNodeSelection, setTextSelection } from '../../../utils';
@@ -22,7 +22,7 @@ import CaptionPlaceholder from '../ui/CaptionPlaceholder';
22
22
  import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
23
23
  import { insertAndSelectCaptionFromMediaSinglePos } from '../commands/captions';
24
24
  import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
25
- import { getMediaSinglePixelWidth } from '@atlaskit/editor-common/media-single';
25
+ import { calcMediaSinglePixelWidth, MEDIA_SINGLE_GUTTER_SIZE, DEFAULT_IMAGE_HEIGHT, DEFAULT_IMAGE_WIDTH } from '@atlaskit/editor-common/media-single';
26
26
  import { getBooleanFF } from '@atlaskit/platform-feature-flags';
27
27
  export default class MediaSingleNode extends Component {
28
28
  constructor(...args) {
@@ -270,16 +270,25 @@ export default class MediaSingleNode extends Component {
270
270
  height = DEFAULT_IMAGE_HEIGHT;
271
271
  }
272
272
  const isSelected = selected();
273
+ const contentWidth = this.getLineLength(view, getPos()) || lineLength;
273
274
  const mediaSingleProps = {
274
275
  layout,
275
276
  width,
276
277
  height,
277
278
  containerWidth: containerWidth,
278
- lineLength: this.getLineLength(view, getPos()) || lineLength,
279
+ lineLength: contentWidth,
279
280
  pctWidth: mediaSingleWidthAttribute,
280
281
  fullWidthMode,
281
282
  hasFallbackContainer: false,
282
- mediaSingleWidth: mediaSingleWidthAttribute && getMediaSinglePixelWidth(mediaSingleWidthAttribute, lineLength, widthType)
283
+ mediaSingleWidth: calcMediaSinglePixelWidth({
284
+ width: mediaSingleWidthAttribute,
285
+ widthType,
286
+ origWidth: width,
287
+ layout,
288
+ contentWidth,
289
+ containerWidth,
290
+ gutterOffset: MEDIA_SINGLE_GUTTER_SIZE
291
+ })
283
292
  };
284
293
  const ResizableMediaSingleProps = {
285
294
  view: view,
@@ -4,7 +4,7 @@ import React from 'react';
4
4
  import { jsx } from '@emotion/react';
5
5
  import { findParentNodeOfTypeClosestToPos, hasParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
6
6
  import { getMediaClient } from '@atlaskit/media-client';
7
- import { calcPctFromPx, wrappedLayouts, handleSides, imageAlignmentMap, calcColumnsFromPx, DEFAULT_IMAGE_WIDTH } from '@atlaskit/editor-common/ui';
7
+ import { calcPctFromPx, wrappedLayouts, handleSides, imageAlignmentMap, calcColumnsFromPx } from '@atlaskit/editor-common/ui';
8
8
  import { nonWrappedLayouts, setNodeSelection } from '@atlaskit/editor-common/utils';
9
9
  import { akEditorFullWidthLayoutWidth, akEditorGutterPadding, akEditorDefaultLayoutWidth } from '@atlaskit/editor-shared-styles';
10
10
  import { wrapperStyle } from './styled';
@@ -15,9 +15,9 @@ import { messages } from './resizable-media-single-messages';
15
15
  import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
16
16
  import classnames from 'classnames';
17
17
  import { richMediaClassName, resizerStyles } from '@atlaskit/editor-common/styles';
18
- import { MEDIA_SINGLE_MIN_PIXEL_WIDTH, MEDIA_SINGLE_SNAP_GAP, MEDIA_SINGLE_HIGHLIGHT_GAP } from '@atlaskit/editor-common/media-single';
19
- import { findClosestSnap, getSnapWidth, getGuidelinesWithHighlights } from '@atlaskit/editor-common/guideline';
20
- import { generateDefaultGuidelines, generateDynamicGuidelines } from './guidelines';
18
+ import { MEDIA_SINGLE_MIN_PIXEL_WIDTH, MEDIA_SINGLE_SNAP_GAP, MEDIA_SINGLE_HIGHLIGHT_GAP, DEFAULT_IMAGE_WIDTH } from '@atlaskit/editor-common/media-single';
19
+ import { findClosestSnap, getSnapWidth, getGuidelinesWithHighlights, generateDynamicGuidelines } from '@atlaskit/editor-common/guideline';
20
+ import { generateDefaultGuidelines } from './guidelines';
21
21
  export const resizerNextTestId = 'mediaSingle.resizerNext.testid';
22
22
  export function calcOffsetLeft(insideInlineLike, insideLayout, pmViewDom, wrapper) {
23
23
  if (wrapper && insideInlineLike && !insideLayout) {
@@ -119,7 +119,7 @@ class ResizableMediaSingleNext extends React.Component {
119
119
  tr.setMeta('mediaSinglePlugin.isResizing', isResizing);
120
120
  return dispatch(tr);
121
121
  });
122
- const initialWidth = props.mediaSingleWidth || this.calcInitialWidth();
122
+ const initialWidth = props.mediaSingleWidth || DEFAULT_IMAGE_WIDTH;
123
123
  this.state = {
124
124
  offsetLeft: calcOffsetLeft(this.insideInlineLike, this.insideLayout, this.props.view.dom, undefined),
125
125
  // We default to true until we resolve the file type
@@ -165,10 +165,10 @@ class ResizableMediaSingleNext extends React.Component {
165
165
  const guidelines = this.getDefaultGuidelines();
166
166
  this.displayGuideline(guidelines);
167
167
  }
168
- if (prevProps.lineLength === undefined && this.props.lineLength !== undefined && this.props.mediaSingleWidth === null) {
169
- // re-initalises size when lineLength becomes defined later
168
+ if (prevProps.mediaSingleWidth !== this.props.mediaSingleWidth && this.props.mediaSingleWidth) {
169
+ // update size when lineLength becomes defined later
170
170
  // ensures extended experience renders legacy image with the same size as the legacy experience
171
- const initialWidth = this.calcInitialWidth();
171
+ const initialWidth = this.props.mediaSingleWidth;
172
172
  this.setState({
173
173
  size: {
174
174
  width: initialWidth,
@@ -198,14 +198,15 @@ class ResizableMediaSingleNext extends React.Component {
198
198
  // TODO: refactor this later, maybe use state to hold snaps array
199
199
  getSnaps() {
200
200
  const {
201
- view
201
+ view,
202
+ lineLength
202
203
  } = this.props;
203
204
  const {
204
205
  dom
205
206
  } = view;
206
207
  const defaultGuidelines = this.getDefaultGuidelines();
207
208
  // disable guidelines for nested media single node
208
- const dynamicGuidelines = this.isNestedNode() ? [] : generateDynamicGuidelines(view);
209
+ const dynamicGuidelines = this.isNestedNode() ? [] : generateDynamicGuidelines(view.state, lineLength);
209
210
  const guidelines = [...defaultGuidelines, ...dynamicGuidelines];
210
211
  const mediaSingleSelector = 'div.mediaSingleView-content-wrap.ProseMirror-selectednode';
211
212
  const {
@@ -2,18 +2,16 @@ import { Fragment, Slice } from '@atlaskit/editor-prosemirror/model';
2
2
  import { safeInsert as pmSafeInsert, hasParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
3
3
  import { checkNodeDown } from '../../../utils';
4
4
  import { isEmptyParagraph } from '@atlaskit/editor-common/utils';
5
- import { MEDIA_SINGLE_MIN_PIXEL_WIDTH } from '@atlaskit/editor-common/media-single';
5
+ import { getMediaSingleInitialWidth } from '@atlaskit/editor-common/media-single';
6
6
  import { copyOptionalAttrsFromMediaState } from '../utils/media-common';
7
7
  import { mapSlice } from '../../../utils/slice';
8
8
  import { addAnalytics } from '../../analytics';
9
- import { akEditorDefaultLayoutWidth } from '@atlaskit/editor-shared-styles';
10
9
  import { ACTION, ACTION_SUBJECT, EVENT_TYPE, ACTION_SUBJECT_ID } from '@atlaskit/editor-common/analytics';
11
10
  import { safeInsert, shouldSplitSelectedNodeOnNodeInsertion } from '@atlaskit/editor-common/insert';
12
11
  import { isImage } from './is-image';
13
12
  import { atTheBeginningOfBlock } from '../../../utils/prosemirror/position';
14
13
  import { getRandomHex } from '@atlaskit/media-common';
15
14
  import { getBooleanFF } from '@atlaskit/platform-feature-flags';
16
- import { DEFAULT_IMAGE_WIDTH } from '@atlaskit/editor-common/ui';
17
15
  const getInsertMediaAnalytics = (inputMethod, fileExtension) => ({
18
16
  action: ACTION.INSERTED,
19
17
  actionSubject: ACTION_SUBJECT.DOCUMENT,
@@ -97,7 +95,9 @@ export const insertMediaSingleNode = (view, mediaState, inputMethod, collection,
97
95
  // add undefined as fallback as we don't want media single width to have upper limit as 0
98
96
  // if widthPluginState.width is 0, default 760 will be used
99
97
  const contentWidth = (widthPluginState === null || widthPluginState === void 0 ? void 0 : widthPluginState.lineLength) || (widthPluginState === null || widthPluginState === void 0 ? void 0 : widthPluginState.width) || undefined;
100
- const node = createMediaSingleNode(state.schema, collection, contentWidth, undefined, alignLeftOnInsert)(mediaState);
98
+ const node = createMediaSingleNode(state.schema, collection, contentWidth,
99
+ // pass undefined to use default min width
100
+ undefined, alignLeftOnInsert)(mediaState);
101
101
  let fileExtension;
102
102
  if (mediaState.fileName) {
103
103
  const extensionIdx = mediaState.fileName.lastIndexOf('.');
@@ -130,7 +130,7 @@ export const insertMediaSingleNode = (view, mediaState, inputMethod, collection,
130
130
  }
131
131
  return true;
132
132
  };
133
- export const createMediaSingleNode = (schema, collection, maxWidth = akEditorDefaultLayoutWidth, minWidth = MEDIA_SINGLE_MIN_PIXEL_WIDTH, alignLeftOnInsert) => mediaState => {
133
+ export const createMediaSingleNode = (schema, collection, maxWidth, minWidth, alignLeftOnInsert) => mediaState => {
134
134
  const {
135
135
  id,
136
136
  dimensions,
@@ -162,8 +162,7 @@ export const createMediaSingleNode = (schema, collection, maxWidth = akEditorDef
162
162
  } : {};
163
163
  const extendedMediaSingleAttrs = getBooleanFF('platform.editor.media.extended-resize-experience') ? {
164
164
  ...mediaSingleAttrs,
165
- // constrain initial width between max width (editor content width) and min width (default to 24)
166
- width: Math.max(Math.min(scaledWidth || DEFAULT_IMAGE_WIDTH, maxWidth), minWidth),
165
+ width: getMediaSingleInitialWidth(scaledWidth, maxWidth, minWidth),
167
166
  // TODO: change to use enum
168
167
  widthType: 'pixel'
169
168
  } : mediaSingleAttrs;
@@ -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());