@atlaskit/editor-core 189.3.14 → 189.3.16

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 (229) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/dist/cjs/nodeviews/getInlineNodeViewProducer.styles.js +1 -1
  3. package/dist/cjs/plugins/analytics/index.js +0 -6
  4. package/dist/cjs/plugins/analytics/utils.js +0 -29
  5. package/dist/cjs/plugins/breakout/index.js +3 -3
  6. package/dist/cjs/plugins/breakout/ui/LayoutButton.js +4 -4
  7. package/dist/cjs/plugins/extension/extension-api.js +3 -3
  8. package/dist/cjs/plugins/extension/index.js +14 -3
  9. package/dist/cjs/plugins/{macro → extension/pm-plugins/macro}/actions.js +3 -4
  10. package/dist/cjs/plugins/{macro → extension/pm-plugins/macro}/index.js +2 -18
  11. package/dist/cjs/plugins/extension/toolbar.js +1 -1
  12. package/dist/cjs/plugins/find-replace/FindReplaceToolbarButtonWithState.js +32 -30
  13. package/dist/cjs/plugins/find-replace/commands-with-analytics.js +85 -71
  14. package/dist/cjs/plugins/find-replace/index.js +5 -2
  15. package/dist/cjs/plugins/find-replace/keymap.js +4 -4
  16. package/dist/cjs/plugins/index.js +1 -24
  17. package/dist/cjs/plugins/insert-block/index.js +36 -53
  18. package/dist/cjs/{ui → plugins/insert-block/ui}/ElementBrowser/InsertMenu.js +3 -9
  19. package/dist/cjs/plugins/insert-block/ui/ToolbarInsertBlock/block-insert-element-browser.js +1 -1
  20. package/dist/cjs/plugins/insert-block/ui/ToolbarInsertBlock/create-items.js +1 -1
  21. package/dist/cjs/plugins/insert-block/ui/ToolbarInsertBlock/dropdown-button.js +3 -3
  22. package/dist/cjs/plugins/insert-block/ui/ToolbarInsertBlock/index.js +4 -5
  23. package/dist/cjs/plugins/insert-block/ui/ToolbarInsertBlock/item.js +7 -8
  24. package/dist/cjs/plugins/paste/handlers.js +3 -3
  25. package/dist/cjs/plugins/paste/pm-plugins/main.js +4 -4
  26. package/dist/cjs/presets/context.js +5 -3
  27. package/dist/cjs/presets/universal.js +12 -8
  28. package/dist/cjs/ui/Appearance/Comment/Comment.js +1 -1
  29. package/dist/cjs/ui/Appearance/FullPage/FullPageToolbar.js +3 -2
  30. package/dist/cjs/{plugins/expand/ui/styles.js → ui/ContentStyles/expand.js} +11 -8
  31. package/dist/cjs/ui/ContentStyles/index.js +4 -4
  32. package/dist/cjs/ui/ToolbarFeedback/index.js +1 -1
  33. package/dist/cjs/use-preset.js +0 -1
  34. package/dist/cjs/version-wrapper.js +1 -1
  35. package/dist/es2019/nodeviews/getInlineNodeViewProducer.styles.js +1 -1
  36. package/dist/es2019/plugins/analytics/index.js +1 -1
  37. package/dist/es2019/plugins/analytics/utils.js +0 -24
  38. package/dist/es2019/plugins/breakout/index.js +1 -1
  39. package/dist/es2019/plugins/breakout/ui/LayoutButton.js +1 -1
  40. package/dist/es2019/plugins/extension/extension-api.js +2 -2
  41. package/dist/es2019/plugins/extension/index.js +13 -3
  42. package/dist/es2019/plugins/{macro → extension/pm-plugins/macro}/actions.js +2 -2
  43. package/dist/es2019/plugins/{macro → extension/pm-plugins/macro}/index.js +1 -14
  44. package/dist/es2019/plugins/extension/toolbar.js +1 -1
  45. package/dist/es2019/plugins/find-replace/FindReplaceToolbarButtonWithState.js +20 -19
  46. package/dist/es2019/plugins/find-replace/commands-with-analytics.js +15 -15
  47. package/dist/es2019/plugins/find-replace/index.js +7 -2
  48. package/dist/es2019/plugins/find-replace/keymap.js +4 -4
  49. package/dist/es2019/plugins/index.js +0 -2
  50. package/dist/es2019/plugins/insert-block/index.js +19 -36
  51. package/dist/es2019/{ui → plugins/insert-block/ui}/ElementBrowser/InsertMenu.js +4 -8
  52. package/dist/es2019/plugins/insert-block/ui/ToolbarInsertBlock/block-insert-element-browser.js +1 -1
  53. package/dist/es2019/plugins/insert-block/ui/ToolbarInsertBlock/create-items.js +1 -1
  54. package/dist/es2019/plugins/insert-block/ui/ToolbarInsertBlock/dropdown-button.js +2 -2
  55. package/dist/es2019/plugins/insert-block/ui/ToolbarInsertBlock/index.js +2 -3
  56. package/dist/es2019/plugins/insert-block/ui/ToolbarInsertBlock/item.js +2 -2
  57. package/dist/es2019/plugins/paste/handlers.js +4 -3
  58. package/dist/es2019/plugins/paste/pm-plugins/main.js +4 -4
  59. package/dist/es2019/presets/context.js +2 -2
  60. package/dist/es2019/presets/universal.js +10 -6
  61. package/dist/es2019/ui/Appearance/Comment/Comment.js +1 -1
  62. package/dist/es2019/ui/Appearance/FullPage/FullPageToolbar.js +3 -2
  63. package/dist/es2019/{plugins/expand/ui/styles.js → ui/ContentStyles/expand.js} +9 -4
  64. package/dist/es2019/ui/ContentStyles/index.js +1 -1
  65. package/dist/es2019/ui/ToolbarFeedback/index.js +2 -2
  66. package/dist/es2019/use-preset.js +0 -1
  67. package/dist/es2019/version-wrapper.js +1 -1
  68. package/dist/esm/nodeviews/getInlineNodeViewProducer.styles.js +1 -1
  69. package/dist/esm/plugins/analytics/index.js +1 -1
  70. package/dist/esm/plugins/analytics/utils.js +0 -28
  71. package/dist/esm/plugins/breakout/index.js +1 -1
  72. package/dist/esm/plugins/breakout/ui/LayoutButton.js +1 -1
  73. package/dist/esm/plugins/extension/extension-api.js +2 -2
  74. package/dist/esm/plugins/extension/index.js +14 -3
  75. package/dist/esm/plugins/{macro → extension/pm-plugins/macro}/actions.js +2 -2
  76. package/dist/esm/plugins/{macro → extension/pm-plugins/macro}/index.js +1 -17
  77. package/dist/esm/plugins/extension/toolbar.js +1 -1
  78. package/dist/esm/plugins/find-replace/FindReplaceToolbarButtonWithState.js +32 -30
  79. package/dist/esm/plugins/find-replace/commands-with-analytics.js +84 -70
  80. package/dist/esm/plugins/find-replace/index.js +5 -2
  81. package/dist/esm/plugins/find-replace/keymap.js +4 -4
  82. package/dist/esm/plugins/index.js +0 -2
  83. package/dist/esm/plugins/insert-block/index.js +36 -53
  84. package/dist/esm/{ui → plugins/insert-block/ui}/ElementBrowser/InsertMenu.js +4 -10
  85. package/dist/esm/plugins/insert-block/ui/ToolbarInsertBlock/block-insert-element-browser.js +1 -1
  86. package/dist/esm/plugins/insert-block/ui/ToolbarInsertBlock/create-items.js +1 -1
  87. package/dist/esm/plugins/insert-block/ui/ToolbarInsertBlock/dropdown-button.js +2 -2
  88. package/dist/esm/plugins/insert-block/ui/ToolbarInsertBlock/index.js +2 -3
  89. package/dist/esm/plugins/insert-block/ui/ToolbarInsertBlock/item.js +2 -2
  90. package/dist/esm/plugins/paste/handlers.js +4 -3
  91. package/dist/esm/plugins/paste/pm-plugins/main.js +4 -4
  92. package/dist/esm/presets/context.js +2 -2
  93. package/dist/esm/presets/universal.js +9 -6
  94. package/dist/esm/ui/Appearance/Comment/Comment.js +1 -1
  95. package/dist/esm/ui/Appearance/FullPage/FullPageToolbar.js +3 -2
  96. package/dist/esm/{plugins/expand/ui/styles.js → ui/ContentStyles/expand.js} +9 -4
  97. package/dist/esm/ui/ContentStyles/index.js +1 -1
  98. package/dist/esm/ui/ToolbarFeedback/index.js +1 -1
  99. package/dist/esm/use-preset.js +0 -1
  100. package/dist/esm/version-wrapper.js +1 -1
  101. package/dist/types/plugins/analytics/index.d.ts +1 -1
  102. package/dist/types/plugins/analytics/utils.d.ts +0 -11
  103. package/dist/types/plugins/extension/extension-api.d.ts +1 -1
  104. package/dist/{types-ts4.5/plugins → types/plugins/extension/pm-plugins}/macro/index.d.ts +1 -4
  105. package/dist/types/plugins/extension/pm-plugins/macro/types.d.ts +4 -0
  106. package/dist/types/plugins/find-replace/FindReplaceToolbarButtonWithState.d.ts +4 -2
  107. package/dist/types/plugins/find-replace/commands-with-analytics.d.ts +9 -9
  108. package/dist/types/plugins/find-replace/index.d.ts +5 -3
  109. package/dist/types/plugins/find-replace/keymap.d.ts +2 -1
  110. package/dist/types/plugins/index.d.ts +0 -2
  111. package/dist/types/plugins/insert-block/types.d.ts +4 -2
  112. package/dist/{types-ts4.5 → types/plugins/insert-block}/ui/ElementBrowser/types.d.ts +2 -2
  113. package/dist/types/plugins/insert-block/ui/ToolbarInsertBlock/block-insert-element-browser.d.ts +1 -1
  114. package/dist/types/plugins/insert-block/ui/ToolbarInsertBlock/block-insert-menu.d.ts +1 -1
  115. package/dist/types/plugins/insert-block/ui/ToolbarInsertBlock/create-items.d.ts +0 -2
  116. package/dist/types/plugins/insert-block/ui/ToolbarInsertBlock/dropdown-button.d.ts +1 -1
  117. package/dist/types/plugins/insert-block/ui/ToolbarInsertBlock/types.d.ts +0 -1
  118. package/dist/types/plugins/mobile-dimensions/index.d.ts +2 -1
  119. package/dist/types/plugins/paste/handlers.d.ts +2 -1
  120. package/dist/types/presets/context.d.ts +2 -2
  121. package/dist/types/presets/default.d.ts +8 -0
  122. package/dist/types/presets/universal.d.ts +5 -0
  123. package/dist/types/{plugins/expand/ui/styles.d.ts → ui/ContentStyles/expand.d.ts} +1 -1
  124. package/dist/types-ts4.5/plugins/analytics/index.d.ts +1 -1
  125. package/dist/types-ts4.5/plugins/analytics/utils.d.ts +0 -11
  126. package/dist/types-ts4.5/plugins/extension/extension-api.d.ts +1 -1
  127. package/dist/{types/plugins → types-ts4.5/plugins/extension/pm-plugins}/macro/index.d.ts +1 -4
  128. package/dist/types-ts4.5/plugins/extension/pm-plugins/macro/types.d.ts +4 -0
  129. package/dist/types-ts4.5/plugins/find-replace/FindReplaceToolbarButtonWithState.d.ts +4 -2
  130. package/dist/types-ts4.5/plugins/find-replace/commands-with-analytics.d.ts +9 -9
  131. package/dist/types-ts4.5/plugins/find-replace/index.d.ts +6 -3
  132. package/dist/types-ts4.5/plugins/find-replace/keymap.d.ts +2 -1
  133. package/dist/types-ts4.5/plugins/index.d.ts +0 -2
  134. package/dist/types-ts4.5/plugins/insert-block/types.d.ts +4 -2
  135. package/dist/{types → types-ts4.5/plugins/insert-block}/ui/ElementBrowser/types.d.ts +2 -2
  136. package/dist/types-ts4.5/plugins/insert-block/ui/ToolbarInsertBlock/block-insert-element-browser.d.ts +1 -1
  137. package/dist/types-ts4.5/plugins/insert-block/ui/ToolbarInsertBlock/block-insert-menu.d.ts +1 -1
  138. package/dist/types-ts4.5/plugins/insert-block/ui/ToolbarInsertBlock/create-items.d.ts +0 -2
  139. package/dist/types-ts4.5/plugins/insert-block/ui/ToolbarInsertBlock/dropdown-button.d.ts +1 -1
  140. package/dist/types-ts4.5/plugins/insert-block/ui/ToolbarInsertBlock/types.d.ts +0 -1
  141. package/dist/types-ts4.5/plugins/mobile-dimensions/index.d.ts +2 -1
  142. package/dist/types-ts4.5/plugins/paste/handlers.d.ts +2 -1
  143. package/dist/types-ts4.5/presets/context.d.ts +2 -2
  144. package/dist/types-ts4.5/presets/default.d.ts +8 -0
  145. package/dist/types-ts4.5/presets/universal.d.ts +5 -0
  146. package/dist/types-ts4.5/{plugins/expand/ui/styles.d.ts → ui/ContentStyles/expand.d.ts} +1 -1
  147. package/package.json +5 -9
  148. package/dist/cjs/plugins/breakout/constants.js +0 -10
  149. package/dist/cjs/plugins/expand/commands.js +0 -184
  150. package/dist/cjs/plugins/expand/index.js +0 -111
  151. package/dist/cjs/plugins/expand/nodeviews/index.js +0 -485
  152. package/dist/cjs/plugins/expand/pm-plugins/keymap.js +0 -171
  153. package/dist/cjs/plugins/expand/pm-plugins/main.js +0 -85
  154. package/dist/cjs/plugins/expand/pm-plugins/plugin-factory.js +0 -15
  155. package/dist/cjs/plugins/expand/reducer.js +0 -20
  156. package/dist/cjs/plugins/expand/toolbar.js +0 -59
  157. package/dist/cjs/plugins/expand/ui/ExpandIconButton.js +0 -104
  158. package/dist/cjs/plugins/expand/ui/class-names.js +0 -20
  159. package/dist/cjs/plugins/expand/utils.js +0 -24
  160. package/dist/cjs/ui/ElementBrowser/types.js +0 -5
  161. package/dist/es2019/plugins/breakout/constants.js +0 -4
  162. package/dist/es2019/plugins/expand/commands.js +0 -161
  163. package/dist/es2019/plugins/expand/index.js +0 -95
  164. package/dist/es2019/plugins/expand/nodeviews/index.js +0 -475
  165. package/dist/es2019/plugins/expand/pm-plugins/keymap.js +0 -197
  166. package/dist/es2019/plugins/expand/pm-plugins/main.js +0 -73
  167. package/dist/es2019/plugins/expand/pm-plugins/plugin-factory.js +0 -9
  168. package/dist/es2019/plugins/expand/reducer.js +0 -11
  169. package/dist/es2019/plugins/expand/toolbar.js +0 -52
  170. package/dist/es2019/plugins/expand/ui/ExpandIconButton.js +0 -85
  171. package/dist/es2019/plugins/expand/ui/class-names.js +0 -12
  172. package/dist/es2019/plugins/expand/utils.js +0 -1
  173. package/dist/esm/plugins/breakout/constants.js +0 -4
  174. package/dist/esm/plugins/expand/commands.js +0 -177
  175. package/dist/esm/plugins/expand/index.js +0 -97
  176. package/dist/esm/plugins/expand/nodeviews/index.js +0 -477
  177. package/dist/esm/plugins/expand/pm-plugins/keymap.js +0 -165
  178. package/dist/esm/plugins/expand/pm-plugins/main.js +0 -77
  179. package/dist/esm/plugins/expand/pm-plugins/plugin-factory.js +0 -9
  180. package/dist/esm/plugins/expand/reducer.js +0 -13
  181. package/dist/esm/plugins/expand/toolbar.js +0 -52
  182. package/dist/esm/plugins/expand/ui/ExpandIconButton.js +0 -95
  183. package/dist/esm/plugins/expand/ui/class-names.js +0 -14
  184. package/dist/esm/plugins/expand/utils.js +0 -1
  185. package/dist/esm/plugins/macro/types.js +0 -1
  186. package/dist/esm/ui/ElementBrowser/types.js +0 -1
  187. package/dist/types/plugins/breakout/constants.d.ts +0 -4
  188. package/dist/types/plugins/expand/commands.d.ts +0 -13
  189. package/dist/types/plugins/expand/index.d.ts +0 -31
  190. package/dist/types/plugins/expand/nodeviews/index.d.ts +0 -55
  191. package/dist/types/plugins/expand/pm-plugins/keymap.d.ts +0 -4
  192. package/dist/types/plugins/expand/pm-plugins/main.d.ts +0 -8
  193. package/dist/types/plugins/expand/pm-plugins/plugin-factory.d.ts +0 -3
  194. package/dist/types/plugins/expand/reducer.d.ts +0 -3
  195. package/dist/types/plugins/expand/toolbar.d.ts +0 -3
  196. package/dist/types/plugins/expand/types.d.ts +0 -9
  197. package/dist/types/plugins/expand/ui/ExpandIconButton.d.ts +0 -43
  198. package/dist/types/plugins/expand/ui/class-names.d.ts +0 -11
  199. package/dist/types/plugins/expand/utils.d.ts +0 -1
  200. package/dist/types/plugins/macro/types.d.ts +0 -4
  201. package/dist/types-ts4.5/plugins/breakout/constants.d.ts +0 -4
  202. package/dist/types-ts4.5/plugins/expand/commands.d.ts +0 -13
  203. package/dist/types-ts4.5/plugins/expand/index.d.ts +0 -31
  204. package/dist/types-ts4.5/plugins/expand/nodeviews/index.d.ts +0 -55
  205. package/dist/types-ts4.5/plugins/expand/pm-plugins/keymap.d.ts +0 -4
  206. package/dist/types-ts4.5/plugins/expand/pm-plugins/main.d.ts +0 -8
  207. package/dist/types-ts4.5/plugins/expand/pm-plugins/plugin-factory.d.ts +0 -3
  208. package/dist/types-ts4.5/plugins/expand/reducer.d.ts +0 -3
  209. package/dist/types-ts4.5/plugins/expand/toolbar.d.ts +0 -3
  210. package/dist/types-ts4.5/plugins/expand/types.d.ts +0 -9
  211. package/dist/types-ts4.5/plugins/expand/ui/ExpandIconButton.d.ts +0 -43
  212. package/dist/types-ts4.5/plugins/expand/ui/class-names.d.ts +0 -11
  213. package/dist/types-ts4.5/plugins/expand/utils.d.ts +0 -1
  214. package/dist/types-ts4.5/plugins/macro/types.d.ts +0 -4
  215. /package/dist/cjs/plugins/{macro → extension/pm-plugins/macro}/plugin-key.js +0 -0
  216. /package/dist/cjs/plugins/{expand → extension/pm-plugins/macro}/types.js +0 -0
  217. /package/dist/cjs/plugins/{macro → insert-block/ui/ElementBrowser}/types.js +0 -0
  218. /package/dist/es2019/plugins/{macro → extension/pm-plugins/macro}/plugin-key.js +0 -0
  219. /package/dist/es2019/plugins/{expand → extension/pm-plugins/macro}/types.js +0 -0
  220. /package/dist/es2019/plugins/{macro → insert-block/ui/ElementBrowser}/types.js +0 -0
  221. /package/dist/esm/plugins/{macro → extension/pm-plugins/macro}/plugin-key.js +0 -0
  222. /package/dist/{es2019/ui/ElementBrowser → esm/plugins/extension/pm-plugins/macro}/types.js +0 -0
  223. /package/dist/esm/plugins/{expand → insert-block/ui/ElementBrowser}/types.js +0 -0
  224. /package/dist/types/plugins/{macro → extension/pm-plugins/macro}/actions.d.ts +0 -0
  225. /package/dist/types/plugins/{macro → extension/pm-plugins/macro}/plugin-key.d.ts +0 -0
  226. /package/dist/types/{ui → plugins/insert-block/ui}/ElementBrowser/InsertMenu.d.ts +0 -0
  227. /package/dist/types-ts4.5/plugins/{macro → extension/pm-plugins/macro}/actions.d.ts +0 -0
  228. /package/dist/types-ts4.5/plugins/{macro → extension/pm-plugins/macro}/plugin-key.d.ts +0 -0
  229. /package/dist/types-ts4.5/{ui → plugins/insert-block/ui}/ElementBrowser/InsertMenu.d.ts +0 -0
@@ -1,477 +0,0 @@
1
- import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
- import _createClass from "@babel/runtime/helpers/createClass";
3
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
4
- import React from 'react';
5
- import ReactDOM from 'react-dom';
6
- import { Selection, NodeSelection } from '@atlaskit/editor-prosemirror/state';
7
- import { ExpandIconButton } from '../ui/ExpandIconButton';
8
- import { keyName } from 'w3c-keyname';
9
- import { DOMSerializer } from '@atlaskit/editor-prosemirror/model';
10
- import { expandMessages } from '@atlaskit/editor-common/ui';
11
- import { isEmptyNode } from '../../../utils';
12
- import { updateExpandTitle, toggleExpandExpanded, deleteExpandAtPos, setSelectionInsideExpand } from '../commands';
13
- import { expandClassNames } from '../ui/class-names';
14
- import { GapCursorSelection, Side, RelativeSelectionPos } from '@atlaskit/editor-common/selection';
15
- import { closestElement } from '../../../utils/dom';
16
- function buildExpandClassName(type, expanded) {
17
- return "".concat(expandClassNames.prefix, " ").concat(expandClassNames.type(type), " ").concat(expanded ? expandClassNames.expanded : '');
18
- }
19
- var toDOM = function toDOM(node, intl) {
20
- return ['div', {
21
- // prettier-ignore
22
- 'class': buildExpandClassName(node.type.name, node.attrs.__expanded),
23
- 'data-node-type': node.type.name,
24
- 'data-title': node.attrs.title
25
- }, ['div', {
26
- // prettier-ignore
27
- 'class': expandClassNames.titleContainer,
28
- contenteditable: 'false',
29
- // Element gains access to focus events.
30
- // This is needed to prevent PM gaining access
31
- // on interacting with our controls.
32
- tabindex: '-1'
33
- },
34
- // prettier-ignore
35
- ['div', {
36
- 'class': expandClassNames.icon
37
- }], ['div', {
38
- // prettier-ignore
39
- 'class': expandClassNames.inputContainer
40
- }, ['input', {
41
- // prettier-ignore
42
- 'class': expandClassNames.titleInput,
43
- value: node.attrs.title,
44
- placeholder: intl && intl.formatMessage(expandMessages.expandPlaceholderText) || expandMessages.expandPlaceholderText.defaultMessage,
45
- type: 'text'
46
- }]]],
47
- // prettier-ignore
48
- ['div', {
49
- 'class': expandClassNames.content
50
- }, 0]];
51
- };
52
- export var ExpandNodeView = /*#__PURE__*/function () {
53
- function ExpandNodeView(node, view, getPos, getIntl, isMobile, featureFlags, selectNearNode, api) {
54
- var _this = this;
55
- _classCallCheck(this, ExpandNodeView);
56
- _defineProperty(this, "allowInteractiveExpand", true);
57
- _defineProperty(this, "isMobile", false);
58
- _defineProperty(this, "focusTitle", function () {
59
- if (_this.input) {
60
- var _this$view = _this.view,
61
- state = _this$view.state,
62
- dispatch = _this$view.dispatch;
63
- if (_this.selectNearNode) {
64
- var tr = _this.selectNearNode({
65
- selectionRelativeToNode: RelativeSelectionPos.Start
66
- })(state);
67
- if (dispatch) {
68
- dispatch(tr);
69
- }
70
- }
71
- var pos = _this.getPos();
72
- if (typeof pos === 'number') {
73
- setSelectionInsideExpand(pos)(state, dispatch, _this.view);
74
- }
75
- _this.input.focus();
76
- }
77
- });
78
- _defineProperty(this, "handleIconKeyDown", function (event) {
79
- switch (keyName(event)) {
80
- case 'Tab':
81
- event.preventDefault();
82
- _this.focusTitle();
83
- break;
84
- case 'Enter':
85
- event.preventDefault();
86
- _this.handleClick(event);
87
- break;
88
- }
89
- });
90
- _defineProperty(this, "isAllowInteractiveExpandEnabled", function () {
91
- return _this.featureFlags && !!_this.featureFlags.interactiveExpand;
92
- });
93
- _defineProperty(this, "handleClick", function (event) {
94
- var pos = _this.getPos();
95
- if (typeof pos !== 'number') {
96
- return;
97
- }
98
- var target = event.target;
99
- var _this$view2 = _this.view,
100
- state = _this$view2.state,
101
- dispatch = _this$view2.dispatch;
102
- if (closestElement(target, ".".concat(expandClassNames.icon))) {
103
- var _this$api;
104
- if (!_this.isAllowInteractiveExpandEnabled()) {
105
- return;
106
- }
107
- event.stopPropagation();
108
-
109
- // We blur the editorView, to prevent any keyboard showing on mobile
110
- // When we're interacting with the expand toggle
111
- if (_this.view.dom instanceof HTMLElement) {
112
- _this.view.dom.blur();
113
- }
114
- toggleExpandExpanded((_this$api = _this.api) === null || _this$api === void 0 || (_this$api = _this$api.analytics) === null || _this$api === void 0 ? void 0 : _this$api.actions)(pos, _this.node.type)(state, dispatch);
115
- return;
116
- }
117
- if (target === _this.input) {
118
- event.stopPropagation();
119
- _this.focusTitle();
120
- return;
121
- }
122
- });
123
- _defineProperty(this, "handleInput", function (event) {
124
- var pos = _this.getPos();
125
- if (typeof pos !== 'number') {
126
- return;
127
- }
128
- var target = event.target;
129
- if (target === _this.input) {
130
- event.stopPropagation();
131
- var _this$view3 = _this.view,
132
- state = _this$view3.state,
133
- dispatch = _this$view3.dispatch;
134
- updateExpandTitle(target.value, pos, _this.node.type)(state, dispatch);
135
- }
136
- });
137
- _defineProperty(this, "handleFocus", function (event) {
138
- event.stopImmediatePropagation();
139
- });
140
- _defineProperty(this, "handleTitleKeydown", function (event) {
141
- switch (keyName(event)) {
142
- case 'Enter':
143
- _this.toggleExpand();
144
- break;
145
- case 'Tab':
146
- case 'ArrowDown':
147
- _this.moveToOutsideOfTitle(event);
148
- break;
149
- case 'ArrowRight':
150
- _this.handleArrowRightFromTitle(event);
151
- break;
152
- case 'ArrowLeft':
153
- _this.handleArrowLeftFromTitle(event);
154
- break;
155
- case 'ArrowUp':
156
- _this.setLeftGapCursor(event);
157
- break;
158
- case 'Backspace':
159
- _this.deleteExpand(event);
160
- break;
161
- }
162
- });
163
- _defineProperty(this, "deleteExpand", function (event) {
164
- if (!_this.input) {
165
- return;
166
- }
167
- var pos = _this.getPos();
168
- if (typeof pos !== 'number') {
169
- return;
170
- }
171
- var _this$input = _this.input,
172
- selectionStart = _this$input.selectionStart,
173
- selectionEnd = _this$input.selectionEnd;
174
- if (selectionStart !== selectionEnd || selectionStart !== 0) {
175
- return;
176
- }
177
- var state = _this.view.state;
178
- var expandNode = _this.node;
179
- if (expandNode && isEmptyNode(state.schema)(expandNode)) {
180
- var _this$api2;
181
- deleteExpandAtPos((_this$api2 = _this.api) === null || _this$api2 === void 0 || (_this$api2 = _this$api2.analytics) === null || _this$api2 === void 0 ? void 0 : _this$api2.actions)(pos, expandNode)(state, _this.view.dispatch);
182
- }
183
- });
184
- _defineProperty(this, "toggleExpand", function () {
185
- var pos = _this.getPos();
186
- if (typeof pos !== 'number') {
187
- return;
188
- }
189
- if (_this.isAllowInteractiveExpandEnabled()) {
190
- var _this$api3;
191
- var _this$view4 = _this.view,
192
- state = _this$view4.state,
193
- dispatch = _this$view4.dispatch;
194
- toggleExpandExpanded((_this$api3 = _this.api) === null || _this$api3 === void 0 || (_this$api3 = _this$api3.analytics) === null || _this$api3 === void 0 ? void 0 : _this$api3.actions)(pos, _this.node.type)(state, dispatch);
195
- }
196
- });
197
- _defineProperty(this, "moveToOutsideOfTitle", function (event) {
198
- event.preventDefault();
199
- var _this$view5 = _this.view,
200
- state = _this$view5.state,
201
- dispatch = _this$view5.dispatch;
202
- var expandPos = _this.getPos();
203
- if (typeof expandPos !== 'number') {
204
- return;
205
- }
206
- var pos = expandPos;
207
- if (_this.isCollapsed()) {
208
- pos = expandPos + _this.node.nodeSize;
209
- }
210
- var resolvedPos = state.doc.resolve(pos);
211
- if (!resolvedPos) {
212
- return;
213
- }
214
- if (_this.isCollapsed() && resolvedPos.nodeAfter && ['expand', 'nestedExpand'].indexOf(resolvedPos.nodeAfter.type.name) > -1) {
215
- return _this.setRightGapCursor(event);
216
- }
217
- var sel = Selection.findFrom(resolvedPos, 1, true);
218
- if (sel) {
219
- // If the input has focus, ProseMirror doesn't
220
- // Give PM focus back before changing our selection
221
- _this.view.focus();
222
- dispatch(state.tr.setSelection(sel));
223
- }
224
- });
225
- _defineProperty(this, "isCollapsed", function () {
226
- return !_this.node.attrs.__expanded;
227
- });
228
- _defineProperty(this, "setRightGapCursor", function (event) {
229
- if (!_this.input) {
230
- return;
231
- }
232
- var pos = _this.getPos();
233
- if (typeof pos !== 'number') {
234
- return;
235
- }
236
- var _this$input2 = _this.input,
237
- value = _this$input2.value,
238
- selectionStart = _this$input2.selectionStart,
239
- selectionEnd = _this$input2.selectionEnd;
240
- if (selectionStart === selectionEnd && selectionStart === value.length) {
241
- var _this$view6 = _this.view,
242
- state = _this$view6.state,
243
- dispatch = _this$view6.dispatch;
244
- event.preventDefault();
245
- _this.view.focus();
246
- dispatch(state.tr.setSelection(new GapCursorSelection(state.doc.resolve(_this.node.nodeSize + pos), Side.RIGHT)));
247
- }
248
- });
249
- _defineProperty(this, "setLeftGapCursor", function (event) {
250
- if (!_this.input) {
251
- return;
252
- }
253
- var pos = _this.getPos();
254
- if (typeof pos !== 'number') {
255
- return;
256
- }
257
- var _this$input3 = _this.input,
258
- selectionStart = _this$input3.selectionStart,
259
- selectionEnd = _this$input3.selectionEnd;
260
- if (selectionStart === selectionEnd && selectionStart === 0) {
261
- event.preventDefault();
262
- var _this$view7 = _this.view,
263
- state = _this$view7.state,
264
- dispatch = _this$view7.dispatch;
265
- _this.view.focus();
266
- dispatch(state.tr.setSelection(new GapCursorSelection(state.doc.resolve(pos), Side.LEFT)));
267
- }
268
- });
269
- _defineProperty(this, "handleArrowRightFromTitle", function (event) {
270
- if (!_this.input || !_this.selectNearNode) {
271
- return;
272
- }
273
- var pos = _this.getPos();
274
- if (typeof pos !== 'number') {
275
- return;
276
- }
277
- var _this$input4 = _this.input,
278
- value = _this$input4.value,
279
- selectionStart = _this$input4.selectionStart,
280
- selectionEnd = _this$input4.selectionEnd;
281
- if (selectionStart === selectionEnd && selectionStart === value.length) {
282
- event.preventDefault();
283
- var _this$view8 = _this.view,
284
- state = _this$view8.state,
285
- dispatch = _this$view8.dispatch;
286
- _this.view.focus();
287
- var tr = _this.selectNearNode({
288
- selectionRelativeToNode: RelativeSelectionPos.End,
289
- selection: NodeSelection.create(state.doc, pos)
290
- })(state);
291
- if (dispatch) {
292
- dispatch(tr);
293
- }
294
- }
295
- });
296
- _defineProperty(this, "handleArrowLeftFromTitle", function (event) {
297
- if (!_this.input || !_this.selectNearNode) {
298
- return;
299
- }
300
- var pos = _this.getPos();
301
- if (typeof pos !== 'number') {
302
- return;
303
- }
304
- var _this$input5 = _this.input,
305
- selectionStart = _this$input5.selectionStart,
306
- selectionEnd = _this$input5.selectionEnd;
307
- if (selectionStart === selectionEnd && selectionStart === 0) {
308
- var _this$api4;
309
- event.preventDefault();
310
- var _this$view9 = _this.view,
311
- state = _this$view9.state,
312
- dispatch = _this$view9.dispatch;
313
- _this.view.focus();
314
- var selectionSharedState = ((_this$api4 = _this.api) === null || _this$api4 === void 0 || (_this$api4 = _this$api4.selection) === null || _this$api4 === void 0 ? void 0 : _this$api4.sharedState.currentState()) || {};
315
- // selectionRelativeToNode is undefined when user clicked to select node, then hit left to get focus in title
316
- // This is a special case where we want to bypass node selection and jump straight to gap cursor
317
- if ((selectionSharedState === null || selectionSharedState === void 0 ? void 0 : selectionSharedState.selectionRelativeToNode) === undefined) {
318
- var tr = _this.selectNearNode({
319
- selectionRelativeToNode: undefined,
320
- selection: new GapCursorSelection(state.doc.resolve(pos), Side.LEFT)
321
- })(state);
322
- if (dispatch) {
323
- dispatch(tr);
324
- }
325
- } else {
326
- var _tr = _this.selectNearNode({
327
- selectionRelativeToNode: RelativeSelectionPos.Start,
328
- selection: NodeSelection.create(state.doc, pos)
329
- })(state);
330
- if (dispatch) {
331
- dispatch(_tr);
332
- }
333
- }
334
- }
335
- });
336
- this.selectNearNode = selectNearNode;
337
- this.intl = getIntl();
338
- var _DOMSerializer$render = DOMSerializer.renderSpec(document, toDOM(node, this.intl)),
339
- dom = _DOMSerializer$render.dom,
340
- contentDOM = _DOMSerializer$render.contentDOM;
341
- this.getPos = getPos;
342
- this.view = view;
343
- this.node = node;
344
- this.dom = dom;
345
- this.contentDOM = contentDOM;
346
- this.isMobile = isMobile;
347
- this.featureFlags = featureFlags;
348
- this.api = api;
349
- this.icon = this.dom.querySelector(".".concat(expandClassNames.icon));
350
- this.input = this.dom.querySelector(".".concat(expandClassNames.titleInput));
351
- this.titleContainer = this.dom.querySelector(".".concat(expandClassNames.titleContainer));
352
- this.content = this.dom.querySelector(".".concat(expandClassNames.content));
353
- this.renderIcon(this.intl);
354
- this.initHandlers();
355
- }
356
- _createClass(ExpandNodeView, [{
357
- key: "initHandlers",
358
- value: function initHandlers() {
359
- if (this.dom) {
360
- this.dom.addEventListener('click', this.handleClick);
361
- this.dom.addEventListener('input', this.handleInput);
362
- }
363
- if (this.input) {
364
- this.input.addEventListener('keydown', this.handleTitleKeydown);
365
- }
366
- if (this.titleContainer) {
367
- // If the user interacts in our title bar (either toggle or input)
368
- // Prevent ProseMirror from getting a focus event (causes weird selection issues).
369
- this.titleContainer.addEventListener('focus', this.handleFocus);
370
- }
371
- if (this.icon) {
372
- this.icon.addEventListener('keydown', this.handleIconKeyDown);
373
- }
374
- }
375
- }, {
376
- key: "renderIcon",
377
- value: function renderIcon(intl, node) {
378
- if (!this.icon) {
379
- return;
380
- }
381
- var _ref = node && node.attrs || this.node.attrs,
382
- __expanded = _ref.__expanded;
383
- ReactDOM.render( /*#__PURE__*/React.createElement(ExpandIconButton, {
384
- intl: intl,
385
- allowInteractiveExpand: this.isAllowInteractiveExpandEnabled(),
386
- expanded: __expanded
387
- }), this.icon);
388
- }
389
- }, {
390
- key: "stopEvent",
391
- value: function stopEvent(event) {
392
- var target = event.target;
393
- return target === this.input || target === this.icon || !!closestElement(target, ".".concat(expandClassNames.icon));
394
- }
395
- }, {
396
- key: "ignoreMutation",
397
- value: function ignoreMutation(mutationRecord) {
398
- // ME-1931: Mobile relies on composition which creates dom mutations. If we ignore them, prosemirror
399
- // does not recognise the changes and reverts them.
400
- if (this.isMobile && (mutationRecord.type === 'characterData' || mutationRecord.type === 'childList')) {
401
- return false;
402
- }
403
- if (mutationRecord.type === 'selection') {
404
- return false;
405
- }
406
- return true;
407
- }
408
- }, {
409
- key: "update",
410
- value: function update(node, _decorations) {
411
- var _this2 = this;
412
- if (this.node.type === node.type) {
413
- if (this.node.attrs.__expanded !== node.attrs.__expanded) {
414
- // Instead of re-rendering the view on an expand toggle
415
- // we toggle a class name to hide the content and animate the chevron.
416
- if (this.dom) {
417
- this.dom.classList.toggle(expandClassNames.expanded);
418
- this.renderIcon(this && this.intl, node);
419
- }
420
- if (this.content) {
421
- // Disallow interaction/selection inside when collapsed.
422
- this.content.setAttribute('contenteditable', node.attrs.__expanded);
423
- }
424
- }
425
-
426
- // During a collab session the title doesn't sync with other users
427
- // since we're intentionally being less aggressive about re-rendering.
428
- // We also apply a rAF to avoid abrupt continuous replacement of the title.
429
- window.requestAnimationFrame(function () {
430
- if (_this2.input && _this2.node.attrs.title !== _this2.input.value) {
431
- _this2.input.value = _this2.node.attrs.title;
432
- }
433
- });
434
- this.node = node;
435
- return true;
436
- }
437
- return false;
438
- }
439
- }, {
440
- key: "destroy",
441
- value: function destroy() {
442
- if (this.dom) {
443
- this.dom.removeEventListener('click', this.handleClick);
444
- this.dom.removeEventListener('input', this.handleInput);
445
- }
446
- if (this.input) {
447
- this.input.removeEventListener('keydown', this.handleTitleKeydown);
448
- }
449
- if (this.titleContainer) {
450
- this.titleContainer.removeEventListener('focus', this.handleFocus);
451
- }
452
- if (this.icon) {
453
- this.icon.removeEventListener('keydown', this.handleIconKeyDown);
454
- ReactDOM.unmountComponentAtNode(this.icon);
455
- }
456
-
457
- // @ts-ignore - [unblock prosemirror bump] reset non optional prop to undefined to clear reference
458
- this.dom = undefined;
459
- this.contentDOM = undefined;
460
- this.icon = undefined;
461
- this.input = undefined;
462
- this.titleContainer = undefined;
463
- this.content = undefined;
464
- }
465
- }]);
466
- return ExpandNodeView;
467
- }();
468
- export default function (_ref2) {
469
- var getIntl = _ref2.getIntl,
470
- isMobile = _ref2.isMobile,
471
- featureFlags = _ref2.featureFlags,
472
- api = _ref2.api;
473
- return function (node, view, getPos) {
474
- var _api$selection;
475
- return new ExpandNodeView(node, view, getPos, getIntl, isMobile, featureFlags, api === null || api === void 0 || (_api$selection = api.selection) === null || _api$selection === void 0 || (_api$selection = _api$selection.actions) === null || _api$selection === void 0 ? void 0 : _api$selection.selectNearNode, api);
476
- };
477
- }
@@ -1,165 +0,0 @@
1
- import { keymap } from '@atlaskit/editor-prosemirror/keymap';
2
- import { Selection, TextSelection, NodeSelection } from '@atlaskit/editor-prosemirror/state';
3
- import { bindKeymapWithCommand, moveRight, moveLeft, moveUp, moveDown, tab, backspace } from '@atlaskit/editor-common/keymaps';
4
- import { GapCursorSelection, Side, RelativeSelectionPos } from '@atlaskit/editor-common/selection';
5
- import { findExpand } from '../utils';
6
- import { isEmptyNode } from '../../../utils';
7
- import { expandClassNames } from '../ui/class-names';
8
- import { deleteExpand, focusTitle } from '../commands';
9
- import { isPositionNearTableRow } from '@atlaskit/editor-common/utils';
10
- var isExpandNode = function isExpandNode(node) {
11
- return (node === null || node === void 0 ? void 0 : node.type.name) === 'expand' || (node === null || node === void 0 ? void 0 : node.type.name) === 'nestedExpand';
12
- };
13
- var isExpandSelected = function isExpandSelected(selection) {
14
- return selection instanceof NodeSelection && isExpandNode(selection.node);
15
- };
16
- export function expandKeymap(api) {
17
- var list = {};
18
- bindKeymapWithCommand(moveRight.common, function (state, dispatch, editorView) {
19
- if (!editorView) {
20
- return false;
21
- }
22
- var selection = state.selection;
23
- var selectionSharedState = (api === null || api === void 0 ? void 0 : api.selection.sharedState.currentState()) || {};
24
- var selectionRelativeToNode = selectionSharedState.selectionRelativeToNode;
25
- if (isExpandSelected(selection) && selectionRelativeToNode === RelativeSelectionPos.Start) {
26
- return focusTitle(selection.from + 1)(state, dispatch, editorView);
27
- }
28
- return false;
29
- }, list);
30
- bindKeymapWithCommand(moveLeft.common, function (state, dispatch, editorView) {
31
- if (!editorView) {
32
- return false;
33
- }
34
- var selection = state.selection;
35
- var selectionSharedState = (api === null || api === void 0 ? void 0 : api.selection.sharedState.currentState()) || {};
36
- var selectionRelativeToNode = selectionSharedState.selectionRelativeToNode;
37
- if (isExpandSelected(selection) && (selectionRelativeToNode === undefined || selectionRelativeToNode === RelativeSelectionPos.End)) {
38
- return focusTitle(selection.from + 1)(state, dispatch, editorView);
39
- }
40
- return false;
41
- }, list);
42
- bindKeymapWithCommand(tab.common, function (state, dispatch, editorView) {
43
- if (state.selection instanceof NodeSelection && state.selection.node.type === state.schema.nodes.expand && editorView && editorView.dom instanceof HTMLElement) {
44
- var from = state.selection.from;
45
- var expand = editorView.nodeDOM(from);
46
- if (!expand || !(expand instanceof HTMLElement)) {
47
- return false;
48
- }
49
- var iconContainer = expand.querySelector(".".concat(expandClassNames.iconContainer));
50
- if (iconContainer && iconContainer.focus) {
51
- var tr = state.tr;
52
- var pos = state.selection.from;
53
- tr.setSelection(new TextSelection(tr.doc.resolve(pos)));
54
- if (dispatch) {
55
- dispatch(tr);
56
- }
57
- editorView.dom.blur();
58
- iconContainer.focus();
59
- }
60
- return true;
61
- }
62
- return false;
63
- }, list);
64
- bindKeymapWithCommand(moveUp.common, function (state, dispatch, editorView) {
65
- if (!editorView) {
66
- return false;
67
- }
68
- var selection = state.selection,
69
- schema = state.schema;
70
- var nodeBefore = selection.$from.nodeBefore;
71
- if (selection instanceof GapCursorSelection && selection.side === Side.RIGHT && nodeBefore && (nodeBefore.type === schema.nodes.expand || nodeBefore.type === schema.nodes.nestedExpand) && !nodeBefore.attrs.__expanded) {
72
- var _$from = selection.$from;
73
- return focusTitle(Math.max(_$from.pos - 1, 0))(state, dispatch, editorView);
74
- }
75
- var $from = state.selection.$from;
76
- if (editorView.endOfTextblock('up')) {
77
- var expand = findExpand(state);
78
-
79
- // Moving UP in a table should move the cursor to the row above
80
- // however when an expand is in a table cell to the left of the
81
- // current table cell, arrow UP moves the cursor to the left
82
- // see ED-15425
83
- if (isPositionNearTableRow($from, schema, 'before') && !expand) {
84
- return false;
85
- }
86
- var prevCursorPos = Math.max($from.pos - $from.parentOffset - 1, 0);
87
- // move cursor from expand's content to its title
88
- if (expand && expand.start === prevCursorPos) {
89
- return focusTitle(expand.start)(state, dispatch, editorView);
90
- }
91
- var sel = Selection.findFrom(state.doc.resolve(prevCursorPos), -1);
92
- var expandBefore = findExpand(state, sel);
93
- if (sel && expandBefore) {
94
- // moving cursor from outside of an expand to the title when it is collapsed
95
- if (!expandBefore.node.attrs.__expanded) {
96
- return focusTitle(expandBefore.start)(state, dispatch, editorView);
97
- }
98
- // moving cursor from outside of an expand to the content when it is expanded
99
- else if (dispatch) {
100
- dispatch(state.tr.setSelection(sel));
101
- }
102
- return true;
103
- }
104
- }
105
- return false;
106
- }, list);
107
- bindKeymapWithCommand(moveDown.common, function (state, dispatch, editorView) {
108
- if (!editorView) {
109
- return false;
110
- }
111
- var _state$schema$nodes = state.schema.nodes,
112
- expand = _state$schema$nodes.expand,
113
- nestedExpand = _state$schema$nodes.nestedExpand;
114
- var selection = state.selection;
115
- var nodeAfter = selection.$from.nodeAfter;
116
- if (selection instanceof GapCursorSelection && selection.side === Side.LEFT && nodeAfter && (nodeAfter.type === expand || nodeAfter.type === nestedExpand) && !nodeAfter.attrs.__expanded) {
117
- var $from = selection.$from;
118
- return focusTitle($from.pos + 1)(state, dispatch, editorView);
119
- }
120
- if (editorView.endOfTextblock('down')) {
121
- var _$from2 = state.selection.$from;
122
- if (_$from2.depth === 0) {
123
- return false;
124
- }
125
- var $after = state.doc.resolve(_$from2.after());
126
- if ($after.nodeAfter && ($after.nodeAfter.type === expand || $after.nodeAfter.type === nestedExpand)) {
127
- return focusTitle($after.pos + 1)(state, dispatch, editorView);
128
- }
129
- }
130
- return false;
131
- }, list);
132
- bindKeymapWithCommand(backspace.common, function (state, dispatch, editorView) {
133
- var selection = state.selection;
134
- var $from = selection.$from;
135
- if (!editorView || !selection.empty) {
136
- return false;
137
- }
138
- var _state$schema$nodes2 = state.schema.nodes,
139
- expand = _state$schema$nodes2.expand,
140
- nestedExpand = _state$schema$nodes2.nestedExpand;
141
- var expandNode = findExpand(state);
142
- if (!expandNode) {
143
- // @see ED-7977
144
- var sel = Selection.findFrom(state.doc.resolve(Math.max(selection.$from.pos - 1, 0)), -1);
145
- var expandBefore = findExpand(state, sel);
146
- if (expandBefore && (expandBefore.node.type === expand || expandBefore.node.type === nestedExpand) && !expandBefore.node.attrs.__expanded) {
147
- return focusTitle(expandBefore.start)(state, dispatch, editorView);
148
- }
149
- return false;
150
- }
151
- var parentNode = state.doc.nodeAt($from.before(Math.max($from.depth - 1, 1)));
152
- // ED-10012 catch cases where the expand has another node nested within it and
153
- // the backspace should be applied only to the inner node instead of the expand
154
- if (parentNode && !isExpandNode(parentNode)) {
155
- return false;
156
- }
157
- var textSel = Selection.findFrom(state.doc.resolve(expandNode.pos), 1, true);
158
- if (textSel && selection.$from.pos === textSel.$from.pos && isEmptyNode(state.schema)(expandNode.node) && dispatch) {
159
- var _api$analytics;
160
- return deleteExpand(api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions)(state, dispatch);
161
- }
162
- return false;
163
- }, list);
164
- return keymap(list);
165
- }