@atlaskit/editor-plugin-text-formatting 1.2.2 → 1.2.4

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 CHANGED
@@ -1,5 +1,17 @@
1
1
  # @atlaskit/editor-plugin-text-formatting
2
2
 
3
+ ## 1.2.4
4
+
5
+ ### Patch Changes
6
+
7
+ - [#78492](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/78492) [`3b0b93acfd19`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/3b0b93acfd19) - [ux] [CAMPTASKS-123] faulty formatting state for inline nodes
8
+
9
+ ## 1.2.3
10
+
11
+ ### Patch Changes
12
+
13
+ - [#80679](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/80679) [`104eb9443b7e`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/104eb9443b7e) - ED-22553 Updating adf-schema version to 35.6.0
14
+
3
15
  ## 1.2.2
4
16
 
5
17
  ### Patch Changes
@@ -23,7 +23,7 @@ var _utils = require("@atlaskit/editor-common/utils");
23
23
  var _prosemirrorInputRules = require("@atlaskit/prosemirror-input-rules");
24
24
  var _ValidCombinations;
25
25
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
26
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
26
+ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
27
27
  var ValidAutoformatChars = /*#__PURE__*/function (ValidAutoformatChars) {
28
28
  ValidAutoformatChars["STRONG"] = "__";
29
29
  ValidAutoformatChars["STRIKE"] = "~~";
@@ -16,14 +16,33 @@ var _mark = require("@atlaskit/editor-common/mark");
16
16
  var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
17
17
  var _utils = require("@atlaskit/editor-common/utils");
18
18
  var _commands = require("@atlaskit/editor-prosemirror/commands");
19
+ var _state = require("@atlaskit/editor-prosemirror/state");
19
20
  var _textFormatting = _interopRequireWildcard(require("../commands/text-formatting"));
20
21
  var commands = _textFormatting;
21
22
  var _pluginKey = require("./plugin-key");
22
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
23
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
23
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
24
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
24
25
  // TODO: Ideally this should use the custom toggleMark function from @atlaskit/editor-common so we also disable the options when selecting inline nodes but it disables the marks when the selection is empty at this point in time which is undesirable
25
26
  // import { toggleMark } from '@atlaskit/editor-common/mark';
26
27
 
28
+ var isSelectionInlineCursor = function isSelectionInlineCursor(selection) {
29
+ if (selection instanceof _state.NodeSelection) {
30
+ return true;
31
+ }
32
+ return false;
33
+ };
34
+ var checkNodeSelection = function checkNodeSelection(mark, editorState, type) {
35
+ var selection = editorState.selection;
36
+ if (isSelectionInlineCursor(selection)) {
37
+ return false;
38
+ }
39
+ if (type !== null || type !== undefined) {
40
+ return (0, _commands.toggleMark)(mark, {
41
+ type: type
42
+ })(editorState);
43
+ }
44
+ return (0, _commands.toggleMark)(mark)(editorState);
45
+ };
27
46
  var getTextFormattingState = function getTextFormattingState(editorState, editorAnalyticsAPI) {
28
47
  var _editorState$schema$m = editorState.schema.marks,
29
48
  em = _editorState$schema$m.em,
@@ -35,19 +54,19 @@ var getTextFormattingState = function getTextFormattingState(editorState, editor
35
54
  var state = {};
36
55
  if (code) {
37
56
  state.codeActive = (0, _mark.anyMarkActive)(editorState, code.create());
38
- state.codeDisabled = !(0, _commands.toggleMark)(code)(editorState);
57
+ state.codeDisabled = !checkNodeSelection(code, editorState);
39
58
  }
40
59
  if (em) {
41
60
  state.emActive = (0, _mark.anyMarkActive)(editorState, em);
42
- state.emDisabled = state.codeActive ? true : !(0, _commands.toggleMark)(em)(editorState);
61
+ state.emDisabled = state.codeActive ? true : !checkNodeSelection(em, editorState);
43
62
  }
44
63
  if (strike) {
45
64
  state.strikeActive = (0, _mark.anyMarkActive)(editorState, strike);
46
- state.strikeDisabled = state.codeActive ? true : !(0, _commands.toggleMark)(strike)(editorState);
65
+ state.strikeDisabled = state.codeActive ? true : !checkNodeSelection(strike, editorState);
47
66
  }
48
67
  if (strong) {
49
68
  state.strongActive = (0, _mark.anyMarkActive)(editorState, strong);
50
- state.strongDisabled = state.codeActive ? true : !(0, _commands.toggleMark)(strong)(editorState);
69
+ state.strongDisabled = state.codeActive ? true : !checkNodeSelection(strong, editorState);
51
70
  }
52
71
  if (subsup) {
53
72
  var subMark = subsup.create({
@@ -57,17 +76,13 @@ var getTextFormattingState = function getTextFormattingState(editorState, editor
57
76
  type: 'sup'
58
77
  });
59
78
  state.subscriptActive = (0, _mark.anyMarkActive)(editorState, subMark);
60
- state.subscriptDisabled = state.codeActive ? true : !(0, _commands.toggleMark)(subsup, {
61
- type: 'sub'
62
- })(editorState);
79
+ state.subscriptDisabled = state.codeActive ? true : !checkNodeSelection(subsup, editorState, 'sub');
63
80
  state.superscriptActive = (0, _mark.anyMarkActive)(editorState, supMark);
64
- state.superscriptDisabled = state.codeActive ? true : !(0, _commands.toggleMark)(subsup, {
65
- type: 'sup'
66
- })(editorState);
81
+ state.superscriptDisabled = state.codeActive ? true : !checkNodeSelection(subsup, editorState, 'sup');
67
82
  }
68
83
  if (underline) {
69
84
  state.underlineActive = (0, _mark.anyMarkActive)(editorState, underline);
70
- state.underlineDisabled = state.codeActive ? true : !(0, _commands.toggleMark)(underline)(editorState);
85
+ state.underlineDisabled = state.codeActive ? true : !checkNodeSelection(underline, editorState);
71
86
  }
72
87
  return state;
73
88
  };
@@ -12,8 +12,8 @@ var _uiMenu = require("@atlaskit/editor-common/ui-menu");
12
12
  var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
13
13
  var _menuState = require("./hooks/menu-state");
14
14
  var _moreButton = require("./more-button");
15
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
16
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
15
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
16
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
17
17
  var FormattingTextDropdownMenu = exports.FormattingTextDropdownMenu = /*#__PURE__*/_react.default.memo(function (_ref) {
18
18
  var editorView = _ref.editorView,
19
19
  moreButtonLabel = _ref.moreButtonLabel,
@@ -20,8 +20,8 @@ var _commands = require("../../../commands");
20
20
  var _types = require("../types");
21
21
  var _IconsMarkSchema;
22
22
  /** @jsx jsx */
23
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
24
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
23
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
24
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
25
25
  var withToolbarInputMethod = function withToolbarInputMethod(func) {
26
26
  return (0, _preset.editorCommandToPMCommand)(func(_analytics.INPUT_METHOD.TOOLBAR));
27
27
  };
@@ -9,8 +9,8 @@ var _react = _interopRequireWildcard(require("react"));
9
9
  var _react2 = require("@emotion/react");
10
10
  var _styles = require("@atlaskit/editor-common/styles");
11
11
  var _uiMenu = require("@atlaskit/editor-common/ui-menu");
12
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
13
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
12
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
13
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
14
14
  /** @jsx jsx */
15
15
 
16
16
  var SingleToolbarButtons = exports.SingleToolbarButtons = /*#__PURE__*/_react.default.memo(function (_ref) {
@@ -6,10 +6,29 @@ import { anyMarkActive } from '@atlaskit/editor-common/mark';
6
6
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
7
7
  import { shallowEqual } from '@atlaskit/editor-common/utils';
8
8
  import { toggleMark } from '@atlaskit/editor-prosemirror/commands';
9
+ import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
9
10
  import { createInlineCodeFromTextInputWithAnalytics } from '../commands/text-formatting';
10
11
  import * as commands from '../commands/text-formatting';
11
12
  import { pluginKey } from './plugin-key';
12
13
  export { pluginKey };
14
+ const isSelectionInlineCursor = selection => {
15
+ if (selection instanceof NodeSelection) {
16
+ return true;
17
+ }
18
+ return false;
19
+ };
20
+ const checkNodeSelection = (mark, editorState, type) => {
21
+ const selection = editorState.selection;
22
+ if (isSelectionInlineCursor(selection)) {
23
+ return false;
24
+ }
25
+ if (type !== null || type !== undefined) {
26
+ return toggleMark(mark, {
27
+ type: type
28
+ })(editorState);
29
+ }
30
+ return toggleMark(mark)(editorState);
31
+ };
13
32
  const getTextFormattingState = (editorState, editorAnalyticsAPI) => {
14
33
  const {
15
34
  em,
@@ -22,19 +41,19 @@ const getTextFormattingState = (editorState, editorAnalyticsAPI) => {
22
41
  const state = {};
23
42
  if (code) {
24
43
  state.codeActive = anyMarkActive(editorState, code.create());
25
- state.codeDisabled = !toggleMark(code)(editorState);
44
+ state.codeDisabled = !checkNodeSelection(code, editorState);
26
45
  }
27
46
  if (em) {
28
47
  state.emActive = anyMarkActive(editorState, em);
29
- state.emDisabled = state.codeActive ? true : !toggleMark(em)(editorState);
48
+ state.emDisabled = state.codeActive ? true : !checkNodeSelection(em, editorState);
30
49
  }
31
50
  if (strike) {
32
51
  state.strikeActive = anyMarkActive(editorState, strike);
33
- state.strikeDisabled = state.codeActive ? true : !toggleMark(strike)(editorState);
52
+ state.strikeDisabled = state.codeActive ? true : !checkNodeSelection(strike, editorState);
34
53
  }
35
54
  if (strong) {
36
55
  state.strongActive = anyMarkActive(editorState, strong);
37
- state.strongDisabled = state.codeActive ? true : !toggleMark(strong)(editorState);
56
+ state.strongDisabled = state.codeActive ? true : !checkNodeSelection(strong, editorState);
38
57
  }
39
58
  if (subsup) {
40
59
  const subMark = subsup.create({
@@ -44,17 +63,13 @@ const getTextFormattingState = (editorState, editorAnalyticsAPI) => {
44
63
  type: 'sup'
45
64
  });
46
65
  state.subscriptActive = anyMarkActive(editorState, subMark);
47
- state.subscriptDisabled = state.codeActive ? true : !toggleMark(subsup, {
48
- type: 'sub'
49
- })(editorState);
66
+ state.subscriptDisabled = state.codeActive ? true : !checkNodeSelection(subsup, editorState, 'sub');
50
67
  state.superscriptActive = anyMarkActive(editorState, supMark);
51
- state.superscriptDisabled = state.codeActive ? true : !toggleMark(subsup, {
52
- type: 'sup'
53
- })(editorState);
68
+ state.superscriptDisabled = state.codeActive ? true : !checkNodeSelection(subsup, editorState, 'sup');
54
69
  }
55
70
  if (underline) {
56
71
  state.underlineActive = anyMarkActive(editorState, underline);
57
- state.underlineDisabled = state.codeActive ? true : !toggleMark(underline)(editorState);
72
+ state.underlineDisabled = state.codeActive ? true : !checkNodeSelection(underline, editorState);
58
73
  }
59
74
  return state;
60
75
  };
@@ -9,7 +9,7 @@ import _wrapNativeSuper from "@babel/runtime/helpers/wrapNativeSuper";
9
9
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
10
10
  var _ValidCombinations;
11
11
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
12
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
12
+ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
13
13
  import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
14
14
  import { transformSmartCharsMentionsAndEmojis } from '@atlaskit/editor-common/mark';
15
15
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
@@ -6,10 +6,29 @@ import { anyMarkActive } from '@atlaskit/editor-common/mark';
6
6
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
7
7
  import { shallowEqual } from '@atlaskit/editor-common/utils';
8
8
  import { toggleMark } from '@atlaskit/editor-prosemirror/commands';
9
+ import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
9
10
  import { createInlineCodeFromTextInputWithAnalytics } from '../commands/text-formatting';
10
11
  import * as commands from '../commands/text-formatting';
11
12
  import { pluginKey } from './plugin-key';
12
13
  export { pluginKey };
14
+ var isSelectionInlineCursor = function isSelectionInlineCursor(selection) {
15
+ if (selection instanceof NodeSelection) {
16
+ return true;
17
+ }
18
+ return false;
19
+ };
20
+ var checkNodeSelection = function checkNodeSelection(mark, editorState, type) {
21
+ var selection = editorState.selection;
22
+ if (isSelectionInlineCursor(selection)) {
23
+ return false;
24
+ }
25
+ if (type !== null || type !== undefined) {
26
+ return toggleMark(mark, {
27
+ type: type
28
+ })(editorState);
29
+ }
30
+ return toggleMark(mark)(editorState);
31
+ };
13
32
  var getTextFormattingState = function getTextFormattingState(editorState, editorAnalyticsAPI) {
14
33
  var _editorState$schema$m = editorState.schema.marks,
15
34
  em = _editorState$schema$m.em,
@@ -21,19 +40,19 @@ var getTextFormattingState = function getTextFormattingState(editorState, editor
21
40
  var state = {};
22
41
  if (code) {
23
42
  state.codeActive = anyMarkActive(editorState, code.create());
24
- state.codeDisabled = !toggleMark(code)(editorState);
43
+ state.codeDisabled = !checkNodeSelection(code, editorState);
25
44
  }
26
45
  if (em) {
27
46
  state.emActive = anyMarkActive(editorState, em);
28
- state.emDisabled = state.codeActive ? true : !toggleMark(em)(editorState);
47
+ state.emDisabled = state.codeActive ? true : !checkNodeSelection(em, editorState);
29
48
  }
30
49
  if (strike) {
31
50
  state.strikeActive = anyMarkActive(editorState, strike);
32
- state.strikeDisabled = state.codeActive ? true : !toggleMark(strike)(editorState);
51
+ state.strikeDisabled = state.codeActive ? true : !checkNodeSelection(strike, editorState);
33
52
  }
34
53
  if (strong) {
35
54
  state.strongActive = anyMarkActive(editorState, strong);
36
- state.strongDisabled = state.codeActive ? true : !toggleMark(strong)(editorState);
55
+ state.strongDisabled = state.codeActive ? true : !checkNodeSelection(strong, editorState);
37
56
  }
38
57
  if (subsup) {
39
58
  var subMark = subsup.create({
@@ -43,17 +62,13 @@ var getTextFormattingState = function getTextFormattingState(editorState, editor
43
62
  type: 'sup'
44
63
  });
45
64
  state.subscriptActive = anyMarkActive(editorState, subMark);
46
- state.subscriptDisabled = state.codeActive ? true : !toggleMark(subsup, {
47
- type: 'sub'
48
- })(editorState);
65
+ state.subscriptDisabled = state.codeActive ? true : !checkNodeSelection(subsup, editorState, 'sub');
49
66
  state.superscriptActive = anyMarkActive(editorState, supMark);
50
- state.superscriptDisabled = state.codeActive ? true : !toggleMark(subsup, {
51
- type: 'sup'
52
- })(editorState);
67
+ state.superscriptDisabled = state.codeActive ? true : !checkNodeSelection(subsup, editorState, 'sup');
53
68
  }
54
69
  if (underline) {
55
70
  state.underlineActive = anyMarkActive(editorState, underline);
56
- state.underlineDisabled = state.codeActive ? true : !toggleMark(underline)(editorState);
71
+ state.underlineDisabled = state.codeActive ? true : !checkNodeSelection(underline, editorState);
57
72
  }
58
73
  return state;
59
74
  };
package/docs/0-intro.tsx CHANGED
@@ -1,7 +1,8 @@
1
1
  import React from 'react';
2
2
 
3
3
  import { AtlassianInternalWarning, code, md } from '@atlaskit/docs';
4
- import { createEditorUseOnlyNotice } from '@atlaskit/editor-core/docs/editor-use-only';
4
+ // eslint-disable-next-line @atlassian/tangerine/import/entry-points
5
+ import { createEditorUseOnlyNotice } from '@atlaskit/editor-common/doc-utils';
5
6
  import { token } from '@atlaskit/tokens';
6
7
 
7
8
  export default md`
@@ -23,7 +24,7 @@ ${createEditorUseOnlyNotice('Editor Plugin Text Formatting', [
23
24
  ---
24
25
 
25
26
  The \`dependencies\`, \`configuration\`, \`state\`, \`actions\`, and \`commands\` of the plugin are defined
26
- below:
27
+ below:
27
28
 
28
29
  ${code`
29
30
  type TextFormattingPlugin = NextEditorPlugin<
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-text-formatting",
3
- "version": "1.2.2",
3
+ "version": "1.2.4",
4
4
  "description": "Text-formatting plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -32,8 +32,8 @@
32
32
  ".": "./src/index.ts"
33
33
  },
34
34
  "dependencies": {
35
- "@atlaskit/adf-schema": "^35.5.2",
36
- "@atlaskit/editor-common": "^78.10.0",
35
+ "@atlaskit/adf-schema": "^35.6.0",
36
+ "@atlaskit/editor-common": "^78.14.0",
37
37
  "@atlaskit/editor-plugin-analytics": "^1.0.0",
38
38
  "@atlaskit/editor-prosemirror": "3.0.0",
39
39
  "@atlaskit/editor-shared-styles": "^2.9.0",
@@ -78,11 +78,9 @@
78
78
  "ui-components": [
79
79
  "lite-mode"
80
80
  ],
81
- "deprecation": [
82
- "no-deprecated-imports"
83
- ],
81
+ "deprecation": "no-deprecated-imports",
84
82
  "styling": [
85
- "static",
83
+ "emotion",
86
84
  "emotion"
87
85
  ],
88
86
  "imports": [
@@ -91,4 +89,4 @@
91
89
  }
92
90
  },
93
91
  "prettier": "@atlassian/atlassian-frontend-prettier-config-1.0.0"
94
- }
92
+ }