@atlaskit/editor-core 184.0.4 → 185.0.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 (189) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/dist/cjs/create-editor/feature-flags-from-props.js +1 -2
  3. package/dist/cjs/editor-next/index.js +41 -34
  4. package/dist/cjs/editor.js +30 -269
  5. package/dist/cjs/i18n/en_ZZ.js +32 -6
  6. package/dist/cjs/index.js +0 -7
  7. package/dist/cjs/labs/next/presets/default.js +2 -1
  8. package/dist/cjs/plugins/base/index.js +0 -12
  9. package/dist/cjs/plugins/card/nodeviews/blockCard.js +7 -0
  10. package/dist/cjs/plugins/card/nodeviews/embedCard.js +7 -0
  11. package/dist/cjs/plugins/card/nodeviews/inlineCard.js +5 -1
  12. package/dist/cjs/plugins/card/pm-plugins/doc.js +1 -2
  13. package/dist/cjs/plugins/card/toolbar.js +11 -9
  14. package/dist/cjs/plugins/card/ui/LinkToolbarAppearance.js +4 -4
  15. package/dist/cjs/plugins/code-block/index.js +7 -5
  16. package/dist/cjs/plugins/code-block/toolbar.js +5 -5
  17. package/dist/cjs/plugins/copy-button/commands.js +2 -3
  18. package/dist/cjs/plugins/copy-button/toolbar.js +7 -8
  19. package/dist/cjs/plugins/expand/index.js +1 -1
  20. package/dist/cjs/plugins/expand/toolbar.js +40 -39
  21. package/dist/cjs/plugins/extension/index.js +1 -1
  22. package/dist/cjs/plugins/extension/toolbar.js +5 -5
  23. package/dist/cjs/plugins/floating-toolbar/index.js +3 -2
  24. package/dist/cjs/plugins/floating-toolbar/ui/Toolbar.js +2 -4
  25. package/dist/cjs/plugins/layout/index.js +8 -4
  26. package/dist/cjs/plugins/layout/toolbar.js +5 -6
  27. package/dist/cjs/plugins/media/toolbar/index.js +31 -24
  28. package/dist/cjs/plugins/panel/index.js +2 -1
  29. package/dist/cjs/plugins/panel/toolbar.js +7 -7
  30. package/dist/cjs/plugins/placeholder-text/index.js +7 -5
  31. package/dist/cjs/plugins/type-ahead/ui/TypeAheadPopup.js +19 -0
  32. package/dist/cjs/ui/CollapsedEditor/index.js +1 -2
  33. package/dist/cjs/ui/ElementBrowser/components/StatelessElementBrowser.js +5 -3
  34. package/dist/cjs/version-wrapper.js +1 -1
  35. package/dist/cjs/version.json +1 -1
  36. package/dist/es2019/create-editor/feature-flags-from-props.js +1 -2
  37. package/dist/es2019/editor-next/index.js +39 -30
  38. package/dist/es2019/editor.js +29 -232
  39. package/dist/es2019/i18n/en_ZZ.js +32 -6
  40. package/dist/es2019/index.js +1 -2
  41. package/dist/es2019/labs/next/presets/default.js +2 -1
  42. package/dist/es2019/plugins/base/index.js +0 -7
  43. package/dist/es2019/plugins/card/nodeviews/blockCard.js +8 -0
  44. package/dist/es2019/plugins/card/nodeviews/embedCard.js +8 -0
  45. package/dist/es2019/plugins/card/nodeviews/inlineCard.js +5 -1
  46. package/dist/es2019/plugins/card/pm-plugins/doc.js +1 -2
  47. package/dist/es2019/plugins/card/toolbar.js +8 -6
  48. package/dist/es2019/plugins/card/ui/LinkToolbarAppearance.js +2 -2
  49. package/dist/es2019/plugins/code-block/index.js +7 -5
  50. package/dist/es2019/plugins/code-block/toolbar.js +5 -6
  51. package/dist/es2019/plugins/copy-button/commands.js +2 -3
  52. package/dist/es2019/plugins/copy-button/toolbar.js +7 -8
  53. package/dist/es2019/plugins/expand/index.js +1 -1
  54. package/dist/es2019/plugins/expand/toolbar.js +5 -6
  55. package/dist/es2019/plugins/extension/index.js +1 -1
  56. package/dist/es2019/plugins/extension/toolbar.js +5 -6
  57. package/dist/es2019/plugins/floating-toolbar/index.js +3 -2
  58. package/dist/es2019/plugins/floating-toolbar/ui/Toolbar.js +2 -4
  59. package/dist/es2019/plugins/layout/index.js +8 -5
  60. package/dist/es2019/plugins/layout/toolbar.js +5 -6
  61. package/dist/es2019/plugins/media/toolbar/index.js +35 -24
  62. package/dist/es2019/plugins/panel/index.js +2 -2
  63. package/dist/es2019/plugins/panel/toolbar.js +7 -8
  64. package/dist/es2019/plugins/placeholder-text/index.js +7 -5
  65. package/dist/es2019/plugins/type-ahead/ui/TypeAheadPopup.js +21 -0
  66. package/dist/es2019/ui/CollapsedEditor/index.js +1 -2
  67. package/dist/es2019/ui/ElementBrowser/components/StatelessElementBrowser.js +5 -3
  68. package/dist/es2019/version-wrapper.js +1 -1
  69. package/dist/es2019/version.json +1 -1
  70. package/dist/esm/create-editor/feature-flags-from-props.js +1 -2
  71. package/dist/esm/editor-next/index.js +42 -33
  72. package/dist/esm/editor.js +29 -270
  73. package/dist/esm/i18n/en_ZZ.js +32 -6
  74. package/dist/esm/index.js +1 -2
  75. package/dist/esm/labs/next/presets/default.js +2 -1
  76. package/dist/esm/plugins/base/index.js +0 -9
  77. package/dist/esm/plugins/card/nodeviews/blockCard.js +7 -0
  78. package/dist/esm/plugins/card/nodeviews/embedCard.js +7 -0
  79. package/dist/esm/plugins/card/nodeviews/inlineCard.js +5 -1
  80. package/dist/esm/plugins/card/pm-plugins/doc.js +1 -2
  81. package/dist/esm/plugins/card/toolbar.js +7 -6
  82. package/dist/esm/plugins/card/ui/LinkToolbarAppearance.js +2 -2
  83. package/dist/esm/plugins/code-block/index.js +7 -5
  84. package/dist/esm/plugins/code-block/toolbar.js +5 -5
  85. package/dist/esm/plugins/copy-button/commands.js +2 -3
  86. package/dist/esm/plugins/copy-button/toolbar.js +7 -8
  87. package/dist/esm/plugins/expand/index.js +1 -1
  88. package/dist/esm/plugins/expand/toolbar.js +40 -39
  89. package/dist/esm/plugins/extension/index.js +1 -1
  90. package/dist/esm/plugins/extension/toolbar.js +5 -5
  91. package/dist/esm/plugins/floating-toolbar/index.js +3 -2
  92. package/dist/esm/plugins/floating-toolbar/ui/Toolbar.js +2 -4
  93. package/dist/esm/plugins/layout/index.js +8 -4
  94. package/dist/esm/plugins/layout/toolbar.js +5 -6
  95. package/dist/esm/plugins/media/toolbar/index.js +31 -24
  96. package/dist/esm/plugins/panel/index.js +2 -1
  97. package/dist/esm/plugins/panel/toolbar.js +7 -7
  98. package/dist/esm/plugins/placeholder-text/index.js +7 -5
  99. package/dist/esm/plugins/type-ahead/ui/TypeAheadPopup.js +19 -0
  100. package/dist/esm/ui/CollapsedEditor/index.js +1 -2
  101. package/dist/esm/ui/ElementBrowser/components/StatelessElementBrowser.js +5 -3
  102. package/dist/esm/version-wrapper.js +1 -1
  103. package/dist/esm/version.json +1 -1
  104. package/dist/types/editor-next/index.d.ts +0 -6
  105. package/dist/types/editor.d.ts +1 -137
  106. package/dist/types/i18n/en_ZZ.d.ts +28 -2
  107. package/dist/types/index.d.ts +0 -1
  108. package/dist/types/labs/next/presets/cxhtml.d.ts +106 -0
  109. package/dist/types/labs/next/presets/default.d.ts +212 -0
  110. package/dist/types/labs/next/presets/mobile.d.ts +106 -0
  111. package/dist/types/plugins/base/index.d.ts +0 -4
  112. package/dist/types/plugins/card/index.d.ts +2 -2
  113. package/dist/types/plugins/card/nodeviews/blockCard.d.ts +3 -0
  114. package/dist/types/plugins/card/nodeviews/embedCard.d.ts +3 -0
  115. package/dist/types/plugins/card/nodeviews/inlineCard.d.ts +1 -0
  116. package/dist/types/plugins/card/pm-plugins/doc.d.ts +1 -1
  117. package/dist/types/plugins/card/pm-plugins/keymap.d.ts +1 -1
  118. package/dist/types/plugins/card/pm-plugins/main.d.ts +1 -2
  119. package/dist/types/plugins/card/toolbar.d.ts +1 -2
  120. package/dist/types/plugins/card/types.d.ts +1 -1
  121. package/dist/types/plugins/card/ui/EditLinkToolbar.d.ts +1 -2
  122. package/dist/types/plugins/card/ui/link-toolbar-button-group-options.d.ts +1 -1
  123. package/dist/types/plugins/card/ui/types.d.ts +1 -1
  124. package/dist/types/plugins/code-block/index.d.ts +7 -1
  125. package/dist/types/plugins/code-block/toolbar.d.ts +2 -1
  126. package/dist/types/plugins/copy-button/commands.d.ts +2 -1
  127. package/dist/types/plugins/copy-button/toolbar.d.ts +3 -2
  128. package/dist/types/plugins/expand/index.d.ts +2 -1
  129. package/dist/types/plugins/expand/toolbar.d.ts +2 -1
  130. package/dist/types/plugins/extension/index.d.ts +7 -2
  131. package/dist/types/plugins/extension/toolbar.d.ts +2 -1
  132. package/dist/types/plugins/floating-toolbar/index.d.ts +2 -1
  133. package/dist/types/plugins/floating-toolbar/ui/Toolbar.d.ts +3 -1
  134. package/dist/types/plugins/layout/index.d.ts +7 -1
  135. package/dist/types/plugins/layout/toolbar.d.ts +2 -1
  136. package/dist/types/plugins/media/index.d.ts +3 -1
  137. package/dist/types/plugins/panel/index.d.ts +2 -0
  138. package/dist/types/plugins/panel/toolbar.d.ts +3 -2
  139. package/dist/types/plugins/placeholder-text/index.d.ts +3 -1
  140. package/dist/types/ui/CollapsedEditor/index.d.ts +1 -2
  141. package/dist/types-ts4.5/editor-next/index.d.ts +0 -6
  142. package/dist/types-ts4.5/editor.d.ts +1 -137
  143. package/dist/types-ts4.5/i18n/en_ZZ.d.ts +28 -2
  144. package/dist/types-ts4.5/index.d.ts +0 -1
  145. package/dist/types-ts4.5/labs/next/presets/cxhtml.d.ts +122 -0
  146. package/dist/types-ts4.5/labs/next/presets/default.d.ts +244 -0
  147. package/dist/types-ts4.5/labs/next/presets/mobile.d.ts +122 -0
  148. package/dist/types-ts4.5/plugins/base/index.d.ts +0 -4
  149. package/dist/types-ts4.5/plugins/card/index.d.ts +2 -2
  150. package/dist/types-ts4.5/plugins/card/nodeviews/blockCard.d.ts +3 -0
  151. package/dist/types-ts4.5/plugins/card/nodeviews/embedCard.d.ts +3 -0
  152. package/dist/types-ts4.5/plugins/card/nodeviews/inlineCard.d.ts +1 -0
  153. package/dist/types-ts4.5/plugins/card/pm-plugins/doc.d.ts +1 -1
  154. package/dist/types-ts4.5/plugins/card/pm-plugins/keymap.d.ts +1 -1
  155. package/dist/types-ts4.5/plugins/card/pm-plugins/main.d.ts +1 -2
  156. package/dist/types-ts4.5/plugins/card/toolbar.d.ts +1 -2
  157. package/dist/types-ts4.5/plugins/card/types.d.ts +1 -1
  158. package/dist/types-ts4.5/plugins/card/ui/EditLinkToolbar.d.ts +1 -2
  159. package/dist/types-ts4.5/plugins/card/ui/link-toolbar-button-group-options.d.ts +1 -1
  160. package/dist/types-ts4.5/plugins/card/ui/types.d.ts +1 -1
  161. package/dist/types-ts4.5/plugins/code-block/index.d.ts +7 -1
  162. package/dist/types-ts4.5/plugins/code-block/toolbar.d.ts +2 -1
  163. package/dist/types-ts4.5/plugins/copy-button/commands.d.ts +2 -1
  164. package/dist/types-ts4.5/plugins/copy-button/toolbar.d.ts +3 -2
  165. package/dist/types-ts4.5/plugins/expand/index.d.ts +3 -1
  166. package/dist/types-ts4.5/plugins/expand/toolbar.d.ts +2 -1
  167. package/dist/types-ts4.5/plugins/extension/index.d.ts +4 -2
  168. package/dist/types-ts4.5/plugins/extension/toolbar.d.ts +2 -1
  169. package/dist/types-ts4.5/plugins/floating-toolbar/index.d.ts +3 -1
  170. package/dist/types-ts4.5/plugins/floating-toolbar/ui/Toolbar.d.ts +3 -1
  171. package/dist/types-ts4.5/plugins/layout/index.d.ts +7 -1
  172. package/dist/types-ts4.5/plugins/layout/toolbar.d.ts +2 -1
  173. package/dist/types-ts4.5/plugins/media/index.d.ts +3 -1
  174. package/dist/types-ts4.5/plugins/panel/index.d.ts +4 -0
  175. package/dist/types-ts4.5/plugins/panel/toolbar.d.ts +3 -2
  176. package/dist/types-ts4.5/plugins/placeholder-text/index.d.ts +5 -1
  177. package/dist/types-ts4.5/ui/CollapsedEditor/index.d.ts +1 -2
  178. package/package.json +13 -8
  179. package/report.api.md +5 -93
  180. package/dist/cjs/editor-next/editor-migration-component.js +0 -54
  181. package/dist/cjs/plugins/base/pm-plugins/decoration.js +0 -122
  182. package/dist/es2019/editor-next/editor-migration-component.js +0 -30
  183. package/dist/es2019/plugins/base/pm-plugins/decoration.js +0 -111
  184. package/dist/esm/editor-next/editor-migration-component.js +0 -47
  185. package/dist/esm/plugins/base/pm-plugins/decoration.js +0 -113
  186. package/dist/types/editor-next/editor-migration-component.d.ts +0 -6
  187. package/dist/types/plugins/base/pm-plugins/decoration.d.ts +0 -24
  188. package/dist/types-ts4.5/editor-next/editor-migration-component.d.ts +0 -6
  189. package/dist/types-ts4.5/plugins/base/pm-plugins/decoration.d.ts +0 -24
@@ -1,30 +0,0 @@
1
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
- import _extends from "@babel/runtime/helpers/extends";
3
- import React from 'react';
4
- import { createFeatureFlagsFromProps } from '../create-editor/feature-flags-from-props';
5
- import Editor from '../editor';
6
- import EditorNext from './index';
7
- import { defaultProps } from './utils/editorPropTypes';
8
- import useUniversalPreset from '../labs/next/presets/useUniversalPreset';
9
- const EditorNextWrapper = ({
10
- props
11
- }) => {
12
- const preset = useUniversalPreset({
13
- props
14
- });
15
- return /*#__PURE__*/React.createElement(EditorNext, _extends({
16
- preset: preset
17
- }, props));
18
- };
19
- export default class EditorMigrationComponent extends React.Component {
20
- render() {
21
- const featureFlags = createFeatureFlagsFromProps(this.props);
22
- if (!featureFlags.useEditorNext) {
23
- return /*#__PURE__*/React.createElement(Editor, this.props);
24
- }
25
- return /*#__PURE__*/React.createElement(EditorNextWrapper, {
26
- props: this.props
27
- });
28
- }
29
- }
30
- _defineProperty(EditorMigrationComponent, "defaultProps", defaultProps);
@@ -1,111 +0,0 @@
1
- import { DecorationSet, Decoration } from 'prosemirror-view';
2
- import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
3
- import { PluginKey, NodeSelection } from 'prosemirror-state';
4
- import { findParentNodeOfType } from 'prosemirror-utils';
5
- export const decorationStateKey = new PluginKey('decorationPlugin');
6
- export let ACTIONS = /*#__PURE__*/function (ACTIONS) {
7
- ACTIONS[ACTIONS["DECORATION_ADD"] = 0] = "DECORATION_ADD";
8
- ACTIONS[ACTIONS["DECORATION_REMOVE"] = 1] = "DECORATION_REMOVE";
9
- return ACTIONS;
10
- }({});
11
-
12
- /**
13
- *
14
- * @private
15
- * @deprecated
16
- *
17
- * Please use the actions of the base plugin rather than this function
18
- * directly
19
- */
20
- export const hoverDecoration = (nodeType, add, className = 'danger') => (state, dispatch) => {
21
- let from;
22
- let parentNode;
23
- if (state.selection instanceof NodeSelection) {
24
- const selectedNode = state.selection.node;
25
- const nodeTypes = Array.isArray(nodeType) ? nodeType : [nodeType];
26
- const isNodeTypeMatching = nodeTypes.indexOf(selectedNode.type) > -1;
27
- // This adds danger styling if the selected node is the one that requires
28
- // the decoration to be added, e.g. if a layout is selected and the user
29
- // hovers over the layout's delete button.
30
- if (isNodeTypeMatching) {
31
- from = state.selection.from;
32
- parentNode = selectedNode;
33
- }
34
- }
35
-
36
- // This adds danger styling if the selection is not a node selection, OR if
37
- // the selected node is a child of the one that requires the decoration to
38
- // be added, e.g. if a decision item is selected inside a layout and the
39
- // user hovers over the layout's delete button.
40
- const foundParentNode = findParentNodeOfType(nodeType)(state.selection);
41
- if (from === undefined && foundParentNode) {
42
- from = foundParentNode.pos;
43
- parentNode = foundParentNode.node;
44
- }
45
-
46
- // Note: can't use !from as from could be 0, which is falsy but valid
47
- if (from === undefined || parentNode === undefined) {
48
- return false;
49
- }
50
- if (dispatch) {
51
- dispatch(state.tr.setMeta(decorationStateKey, {
52
- action: add ? ACTIONS.DECORATION_ADD : ACTIONS.DECORATION_REMOVE,
53
- data: Decoration.node(from, from + parentNode.nodeSize, {
54
- class: className
55
- }, {
56
- key: 'decorationNode'
57
- })
58
- }).setMeta('addToHistory', false));
59
- }
60
- return true;
61
- };
62
- export default (() => {
63
- return new SafePlugin({
64
- key: decorationStateKey,
65
- state: {
66
- init: () => ({
67
- decoration: undefined
68
- }),
69
- apply(tr, pluginState) {
70
- if (pluginState.decoration) {
71
- const mapResult = tr.mapping.mapResult(pluginState.decoration.from);
72
- if (mapResult.deleted) {
73
- pluginState = {
74
- decoration: undefined
75
- };
76
- }
77
- }
78
- const meta = tr.getMeta(decorationStateKey);
79
- if (!meta) {
80
- return pluginState;
81
- }
82
- switch (meta.action) {
83
- case ACTIONS.DECORATION_ADD:
84
- return {
85
- decoration: meta.data
86
- };
87
- case ACTIONS.DECORATION_REMOVE:
88
- return {
89
- decoration: undefined
90
- };
91
- default:
92
- return pluginState;
93
- }
94
- }
95
- },
96
- props: {
97
- decorations(state) {
98
- const {
99
- doc
100
- } = state;
101
- const {
102
- decoration
103
- } = decorationStateKey.getState(state);
104
- if (decoration) {
105
- return DecorationSet.create(doc, [decoration]);
106
- }
107
- return null;
108
- }
109
- }
110
- });
111
- });
@@ -1,47 +0,0 @@
1
- import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
- import _createClass from "@babel/runtime/helpers/createClass";
3
- import _inherits from "@babel/runtime/helpers/inherits";
4
- import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
5
- import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
6
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
7
- import _extends from "@babel/runtime/helpers/extends";
8
- 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); }; }
9
- 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; } }
10
- import React from 'react';
11
- import { createFeatureFlagsFromProps } from '../create-editor/feature-flags-from-props';
12
- import Editor from '../editor';
13
- import EditorNext from './index';
14
- import { defaultProps } from './utils/editorPropTypes';
15
- import useUniversalPreset from '../labs/next/presets/useUniversalPreset';
16
- var EditorNextWrapper = function EditorNextWrapper(_ref) {
17
- var props = _ref.props;
18
- var preset = useUniversalPreset({
19
- props: props
20
- });
21
- return /*#__PURE__*/React.createElement(EditorNext, _extends({
22
- preset: preset
23
- }, props));
24
- };
25
- var EditorMigrationComponent = /*#__PURE__*/function (_React$Component) {
26
- _inherits(EditorMigrationComponent, _React$Component);
27
- var _super = _createSuper(EditorMigrationComponent);
28
- function EditorMigrationComponent() {
29
- _classCallCheck(this, EditorMigrationComponent);
30
- return _super.apply(this, arguments);
31
- }
32
- _createClass(EditorMigrationComponent, [{
33
- key: "render",
34
- value: function render() {
35
- var featureFlags = createFeatureFlagsFromProps(this.props);
36
- if (!featureFlags.useEditorNext) {
37
- return /*#__PURE__*/React.createElement(Editor, this.props);
38
- }
39
- return /*#__PURE__*/React.createElement(EditorNextWrapper, {
40
- props: this.props
41
- });
42
- }
43
- }]);
44
- return EditorMigrationComponent;
45
- }(React.Component);
46
- _defineProperty(EditorMigrationComponent, "defaultProps", defaultProps);
47
- export { EditorMigrationComponent as default };
@@ -1,113 +0,0 @@
1
- import { DecorationSet, Decoration } from 'prosemirror-view';
2
- import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
3
- import { PluginKey, NodeSelection } from 'prosemirror-state';
4
- import { findParentNodeOfType } from 'prosemirror-utils';
5
- export var decorationStateKey = new PluginKey('decorationPlugin');
6
- export var ACTIONS = /*#__PURE__*/function (ACTIONS) {
7
- ACTIONS[ACTIONS["DECORATION_ADD"] = 0] = "DECORATION_ADD";
8
- ACTIONS[ACTIONS["DECORATION_REMOVE"] = 1] = "DECORATION_REMOVE";
9
- return ACTIONS;
10
- }({});
11
-
12
- /**
13
- *
14
- * @private
15
- * @deprecated
16
- *
17
- * Please use the actions of the base plugin rather than this function
18
- * directly
19
- */
20
- export var hoverDecoration = function hoverDecoration(nodeType, add) {
21
- var className = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'danger';
22
- return function (state, dispatch) {
23
- var from;
24
- var parentNode;
25
- if (state.selection instanceof NodeSelection) {
26
- var selectedNode = state.selection.node;
27
- var nodeTypes = Array.isArray(nodeType) ? nodeType : [nodeType];
28
- var isNodeTypeMatching = nodeTypes.indexOf(selectedNode.type) > -1;
29
- // This adds danger styling if the selected node is the one that requires
30
- // the decoration to be added, e.g. if a layout is selected and the user
31
- // hovers over the layout's delete button.
32
- if (isNodeTypeMatching) {
33
- from = state.selection.from;
34
- parentNode = selectedNode;
35
- }
36
- }
37
-
38
- // This adds danger styling if the selection is not a node selection, OR if
39
- // the selected node is a child of the one that requires the decoration to
40
- // be added, e.g. if a decision item is selected inside a layout and the
41
- // user hovers over the layout's delete button.
42
- var foundParentNode = findParentNodeOfType(nodeType)(state.selection);
43
- if (from === undefined && foundParentNode) {
44
- from = foundParentNode.pos;
45
- parentNode = foundParentNode.node;
46
- }
47
-
48
- // Note: can't use !from as from could be 0, which is falsy but valid
49
- if (from === undefined || parentNode === undefined) {
50
- return false;
51
- }
52
- if (dispatch) {
53
- dispatch(state.tr.setMeta(decorationStateKey, {
54
- action: add ? ACTIONS.DECORATION_ADD : ACTIONS.DECORATION_REMOVE,
55
- data: Decoration.node(from, from + parentNode.nodeSize, {
56
- class: className
57
- }, {
58
- key: 'decorationNode'
59
- })
60
- }).setMeta('addToHistory', false));
61
- }
62
- return true;
63
- };
64
- };
65
- export default (function () {
66
- return new SafePlugin({
67
- key: decorationStateKey,
68
- state: {
69
- init: function init() {
70
- return {
71
- decoration: undefined
72
- };
73
- },
74
- apply: function apply(tr, pluginState) {
75
- if (pluginState.decoration) {
76
- var mapResult = tr.mapping.mapResult(pluginState.decoration.from);
77
- if (mapResult.deleted) {
78
- pluginState = {
79
- decoration: undefined
80
- };
81
- }
82
- }
83
- var meta = tr.getMeta(decorationStateKey);
84
- if (!meta) {
85
- return pluginState;
86
- }
87
- switch (meta.action) {
88
- case ACTIONS.DECORATION_ADD:
89
- return {
90
- decoration: meta.data
91
- };
92
- case ACTIONS.DECORATION_REMOVE:
93
- return {
94
- decoration: undefined
95
- };
96
- default:
97
- return pluginState;
98
- }
99
- }
100
- },
101
- props: {
102
- decorations: function decorations(state) {
103
- var doc = state.doc;
104
- var _ref = decorationStateKey.getState(state),
105
- decoration = _ref.decoration;
106
- if (decoration) {
107
- return DecorationSet.create(doc, [decoration]);
108
- }
109
- return null;
110
- }
111
- }
112
- });
113
- });
@@ -1,6 +0,0 @@
1
- import React from 'react';
2
- import { EditorProps } from '../types/editor-props';
3
- export default class EditorMigrationComponent extends React.Component<EditorProps> {
4
- static defaultProps: EditorProps;
5
- render(): JSX.Element;
6
- }
@@ -1,24 +0,0 @@
1
- import { NodeType } from 'prosemirror-model';
2
- import { Decoration } from 'prosemirror-view';
3
- import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
4
- import { PluginKey } from 'prosemirror-state';
5
- import { Command } from '../../../types';
6
- export declare const decorationStateKey: PluginKey<any, any>;
7
- export declare enum ACTIONS {
8
- DECORATION_ADD = 0,
9
- DECORATION_REMOVE = 1
10
- }
11
- /**
12
- *
13
- * @private
14
- * @deprecated
15
- *
16
- * Please use the actions of the base plugin rather than this function
17
- * directly
18
- */
19
- export declare const hoverDecoration: (nodeType: NodeType | Array<NodeType>, add: boolean, className?: string) => Command;
20
- export type DecorationState = {
21
- decoration?: Decoration;
22
- };
23
- declare const _default: () => SafePlugin<DecorationState, any>;
24
- export default _default;
@@ -1,6 +0,0 @@
1
- import React from 'react';
2
- import { EditorProps } from '../types/editor-props';
3
- export default class EditorMigrationComponent extends React.Component<EditorProps> {
4
- static defaultProps: EditorProps;
5
- render(): JSX.Element;
6
- }
@@ -1,24 +0,0 @@
1
- import { NodeType } from 'prosemirror-model';
2
- import { Decoration } from 'prosemirror-view';
3
- import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
4
- import { PluginKey } from 'prosemirror-state';
5
- import { Command } from '../../../types';
6
- export declare const decorationStateKey: PluginKey<any, any>;
7
- export declare enum ACTIONS {
8
- DECORATION_ADD = 0,
9
- DECORATION_REMOVE = 1
10
- }
11
- /**
12
- *
13
- * @private
14
- * @deprecated
15
- *
16
- * Please use the actions of the base plugin rather than this function
17
- * directly
18
- */
19
- export declare const hoverDecoration: (nodeType: NodeType | Array<NodeType>, add: boolean, className?: string) => Command;
20
- export type DecorationState = {
21
- decoration?: Decoration;
22
- };
23
- declare const _default: () => SafePlugin<DecorationState, any>;
24
- export default _default;