@atlaskit/editor-core 189.1.12 → 189.1.15

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 (260) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/cjs/i18n/cs.js +0 -1
  3. package/dist/cjs/i18n/da.js +0 -1
  4. package/dist/cjs/i18n/de.js +0 -1
  5. package/dist/cjs/i18n/en.js +0 -1
  6. package/dist/cjs/i18n/en_GB.js +0 -1
  7. package/dist/cjs/i18n/en_ZZ.js +0 -1
  8. package/dist/cjs/i18n/es.js +0 -1
  9. package/dist/cjs/i18n/fi.js +0 -1
  10. package/dist/cjs/i18n/fr.js +0 -1
  11. package/dist/cjs/i18n/hu.js +0 -1
  12. package/dist/cjs/i18n/it.js +0 -1
  13. package/dist/cjs/i18n/ja.js +0 -1
  14. package/dist/cjs/i18n/ko.js +0 -1
  15. package/dist/cjs/i18n/nb.js +0 -1
  16. package/dist/cjs/i18n/nl.js +0 -1
  17. package/dist/cjs/i18n/pl.js +0 -1
  18. package/dist/cjs/i18n/pt_BR.js +0 -1
  19. package/dist/cjs/i18n/ru.js +0 -1
  20. package/dist/cjs/i18n/sv.js +0 -1
  21. package/dist/cjs/i18n/th.js +0 -1
  22. package/dist/cjs/i18n/tr.js +0 -1
  23. package/dist/cjs/i18n/uk.js +0 -1
  24. package/dist/cjs/i18n/vi.js +0 -1
  25. package/dist/cjs/i18n/zh.js +0 -1
  26. package/dist/cjs/i18n/zh_TW.js +0 -1
  27. package/dist/cjs/plugins/index.js +0 -7
  28. package/dist/cjs/plugins/insert-block/index.js +6 -10
  29. package/dist/cjs/plugins/insert-block/ui/ToolbarInsertBlock/index.js +40 -38
  30. package/dist/cjs/plugins/panel/actions.js +11 -11
  31. package/dist/cjs/plugins/panel/index.js +4 -4
  32. package/dist/cjs/plugins/panel/nodeviews/panel.js +5 -5
  33. package/dist/cjs/plugins/panel/pm-plugins/keymaps.js +7 -7
  34. package/dist/cjs/plugins/panel/pm-plugins/main.js +2 -2
  35. package/dist/cjs/plugins/panel/toolbar.js +16 -16
  36. package/dist/cjs/plugins/panel/utils.js +1 -1
  37. package/dist/cjs/presets/universal.js +2 -1
  38. package/dist/cjs/ui/ContentStyles/index.js +7 -7
  39. package/dist/cjs/version-wrapper.js +1 -1
  40. package/dist/es2019/i18n/cs.js +0 -1
  41. package/dist/es2019/i18n/da.js +0 -1
  42. package/dist/es2019/i18n/de.js +0 -1
  43. package/dist/es2019/i18n/en.js +0 -1
  44. package/dist/es2019/i18n/en_GB.js +0 -1
  45. package/dist/es2019/i18n/en_ZZ.js +0 -1
  46. package/dist/es2019/i18n/es.js +0 -1
  47. package/dist/es2019/i18n/fi.js +0 -1
  48. package/dist/es2019/i18n/fr.js +0 -1
  49. package/dist/es2019/i18n/hu.js +0 -1
  50. package/dist/es2019/i18n/it.js +0 -1
  51. package/dist/es2019/i18n/ja.js +0 -1
  52. package/dist/es2019/i18n/ko.js +0 -1
  53. package/dist/es2019/i18n/nb.js +0 -1
  54. package/dist/es2019/i18n/nl.js +0 -1
  55. package/dist/es2019/i18n/pl.js +0 -1
  56. package/dist/es2019/i18n/pt_BR.js +0 -1
  57. package/dist/es2019/i18n/ru.js +0 -1
  58. package/dist/es2019/i18n/sv.js +0 -1
  59. package/dist/es2019/i18n/th.js +0 -1
  60. package/dist/es2019/i18n/tr.js +0 -1
  61. package/dist/es2019/i18n/uk.js +0 -1
  62. package/dist/es2019/i18n/vi.js +0 -1
  63. package/dist/es2019/i18n/zh.js +0 -1
  64. package/dist/es2019/i18n/zh_TW.js +0 -1
  65. package/dist/es2019/plugins/index.js +0 -1
  66. package/dist/es2019/plugins/insert-block/index.js +5 -9
  67. package/dist/es2019/plugins/insert-block/ui/ToolbarInsertBlock/index.js +4 -3
  68. package/dist/es2019/plugins/panel/actions.js +5 -5
  69. package/dist/es2019/plugins/panel/index.js +6 -6
  70. package/dist/es2019/plugins/panel/nodeviews/panel.js +5 -5
  71. package/dist/es2019/plugins/panel/pm-plugins/keymaps.js +2 -2
  72. package/dist/es2019/plugins/panel/pm-plugins/main.js +2 -2
  73. package/dist/es2019/plugins/panel/toolbar.js +12 -13
  74. package/dist/es2019/plugins/panel/utils.js +1 -1
  75. package/dist/es2019/presets/universal.js +2 -1
  76. package/dist/es2019/ui/ContentStyles/index.js +2 -2
  77. package/dist/es2019/version-wrapper.js +1 -1
  78. package/dist/esm/i18n/cs.js +0 -1
  79. package/dist/esm/i18n/da.js +0 -1
  80. package/dist/esm/i18n/de.js +0 -1
  81. package/dist/esm/i18n/en.js +0 -1
  82. package/dist/esm/i18n/en_GB.js +0 -1
  83. package/dist/esm/i18n/en_ZZ.js +0 -1
  84. package/dist/esm/i18n/es.js +0 -1
  85. package/dist/esm/i18n/fi.js +0 -1
  86. package/dist/esm/i18n/fr.js +0 -1
  87. package/dist/esm/i18n/hu.js +0 -1
  88. package/dist/esm/i18n/it.js +0 -1
  89. package/dist/esm/i18n/ja.js +0 -1
  90. package/dist/esm/i18n/ko.js +0 -1
  91. package/dist/esm/i18n/nb.js +0 -1
  92. package/dist/esm/i18n/nl.js +0 -1
  93. package/dist/esm/i18n/pl.js +0 -1
  94. package/dist/esm/i18n/pt_BR.js +0 -1
  95. package/dist/esm/i18n/ru.js +0 -1
  96. package/dist/esm/i18n/sv.js +0 -1
  97. package/dist/esm/i18n/th.js +0 -1
  98. package/dist/esm/i18n/tr.js +0 -1
  99. package/dist/esm/i18n/uk.js +0 -1
  100. package/dist/esm/i18n/vi.js +0 -1
  101. package/dist/esm/i18n/zh.js +0 -1
  102. package/dist/esm/i18n/zh_TW.js +0 -1
  103. package/dist/esm/plugins/index.js +0 -1
  104. package/dist/esm/plugins/insert-block/index.js +5 -9
  105. package/dist/esm/plugins/insert-block/ui/ToolbarInsertBlock/index.js +40 -38
  106. package/dist/esm/plugins/panel/actions.js +5 -5
  107. package/dist/esm/plugins/panel/index.js +6 -6
  108. package/dist/esm/plugins/panel/nodeviews/panel.js +5 -5
  109. package/dist/esm/plugins/panel/pm-plugins/keymaps.js +2 -2
  110. package/dist/esm/plugins/panel/pm-plugins/main.js +2 -2
  111. package/dist/esm/plugins/panel/toolbar.js +12 -13
  112. package/dist/esm/plugins/panel/utils.js +1 -1
  113. package/dist/esm/presets/universal.js +2 -1
  114. package/dist/esm/ui/ContentStyles/index.js +2 -2
  115. package/dist/esm/version-wrapper.js +1 -1
  116. package/dist/types/i18n/cs.d.ts +0 -1
  117. package/dist/types/i18n/da.d.ts +0 -1
  118. package/dist/types/i18n/de.d.ts +0 -1
  119. package/dist/types/i18n/en.d.ts +0 -1
  120. package/dist/types/i18n/en_GB.d.ts +0 -1
  121. package/dist/types/i18n/en_ZZ.d.ts +0 -1
  122. package/dist/types/i18n/es.d.ts +0 -1
  123. package/dist/types/i18n/fi.d.ts +0 -1
  124. package/dist/types/i18n/fr.d.ts +0 -1
  125. package/dist/types/i18n/hu.d.ts +0 -1
  126. package/dist/types/i18n/it.d.ts +0 -1
  127. package/dist/types/i18n/ja.d.ts +0 -1
  128. package/dist/types/i18n/ko.d.ts +0 -1
  129. package/dist/types/i18n/nb.d.ts +0 -1
  130. package/dist/types/i18n/nl.d.ts +0 -1
  131. package/dist/types/i18n/pl.d.ts +0 -1
  132. package/dist/types/i18n/pt_BR.d.ts +0 -1
  133. package/dist/types/i18n/ru.d.ts +0 -1
  134. package/dist/types/i18n/sv.d.ts +0 -1
  135. package/dist/types/i18n/th.d.ts +0 -1
  136. package/dist/types/i18n/tr.d.ts +0 -1
  137. package/dist/types/i18n/uk.d.ts +0 -1
  138. package/dist/types/i18n/vi.d.ts +0 -1
  139. package/dist/types/i18n/zh.d.ts +0 -1
  140. package/dist/types/i18n/zh_TW.d.ts +0 -1
  141. package/dist/types/plugins/index.d.ts +0 -1
  142. package/dist/types/plugins/insert-block/types.d.ts +3 -1
  143. package/dist/types/plugins/panel/actions.d.ts +2 -2
  144. package/dist/types/plugins/panel/index.d.ts +3 -3
  145. package/dist/types/plugins/panel/nodeviews/panel.d.ts +3 -3
  146. package/dist/types/plugins/panel/pm-plugins/main.d.ts +2 -2
  147. package/dist/types/plugins/panel/toolbar.d.ts +6 -7
  148. package/dist/types/plugins/panel/types.d.ts +1 -1
  149. package/dist/types/plugins/panel/utils.d.ts +1 -1
  150. package/dist/types/types/editor-props.d.ts +1 -1
  151. package/dist/types/ui/ConfigPanel/ConfigPanel.d.ts +1 -1
  152. package/dist/types/{plugins/panel/styles.d.ts → ui/ContentStyles/panel.d.ts} +1 -1
  153. package/dist/types-ts4.5/i18n/cs.d.ts +0 -1
  154. package/dist/types-ts4.5/i18n/da.d.ts +0 -1
  155. package/dist/types-ts4.5/i18n/de.d.ts +0 -1
  156. package/dist/types-ts4.5/i18n/en.d.ts +0 -1
  157. package/dist/types-ts4.5/i18n/en_GB.d.ts +0 -1
  158. package/dist/types-ts4.5/i18n/en_ZZ.d.ts +0 -1
  159. package/dist/types-ts4.5/i18n/es.d.ts +0 -1
  160. package/dist/types-ts4.5/i18n/fi.d.ts +0 -1
  161. package/dist/types-ts4.5/i18n/fr.d.ts +0 -1
  162. package/dist/types-ts4.5/i18n/hu.d.ts +0 -1
  163. package/dist/types-ts4.5/i18n/it.d.ts +0 -1
  164. package/dist/types-ts4.5/i18n/ja.d.ts +0 -1
  165. package/dist/types-ts4.5/i18n/ko.d.ts +0 -1
  166. package/dist/types-ts4.5/i18n/nb.d.ts +0 -1
  167. package/dist/types-ts4.5/i18n/nl.d.ts +0 -1
  168. package/dist/types-ts4.5/i18n/pl.d.ts +0 -1
  169. package/dist/types-ts4.5/i18n/pt_BR.d.ts +0 -1
  170. package/dist/types-ts4.5/i18n/ru.d.ts +0 -1
  171. package/dist/types-ts4.5/i18n/sv.d.ts +0 -1
  172. package/dist/types-ts4.5/i18n/th.d.ts +0 -1
  173. package/dist/types-ts4.5/i18n/tr.d.ts +0 -1
  174. package/dist/types-ts4.5/i18n/uk.d.ts +0 -1
  175. package/dist/types-ts4.5/i18n/vi.d.ts +0 -1
  176. package/dist/types-ts4.5/i18n/zh.d.ts +0 -1
  177. package/dist/types-ts4.5/i18n/zh_TW.d.ts +0 -1
  178. package/dist/types-ts4.5/plugins/index.d.ts +0 -1
  179. package/dist/types-ts4.5/plugins/insert-block/types.d.ts +3 -1
  180. package/dist/types-ts4.5/plugins/panel/actions.d.ts +2 -2
  181. package/dist/types-ts4.5/plugins/panel/index.d.ts +3 -3
  182. package/dist/types-ts4.5/plugins/panel/nodeviews/panel.d.ts +3 -3
  183. package/dist/types-ts4.5/plugins/panel/pm-plugins/main.d.ts +2 -2
  184. package/dist/types-ts4.5/plugins/panel/toolbar.d.ts +6 -7
  185. package/dist/types-ts4.5/plugins/panel/types.d.ts +1 -1
  186. package/dist/types-ts4.5/plugins/panel/utils.d.ts +1 -1
  187. package/dist/types-ts4.5/types/editor-props.d.ts +1 -1
  188. package/dist/types-ts4.5/ui/ConfigPanel/ConfigPanel.d.ts +1 -1
  189. package/dist/types-ts4.5/{plugins/panel/styles.d.ts → ui/ContentStyles/panel.d.ts} +1 -1
  190. package/package.json +4 -3
  191. package/report.api.md +1 -6
  192. package/tmp/api-report-tmp.d.ts +1 -6
  193. package/dist/cjs/plugins/placeholder-text/actions.js +0 -35
  194. package/dist/cjs/plugins/placeholder-text/fake-text-cursor/cursor.js +0 -107
  195. package/dist/cjs/plugins/placeholder-text/index.js +0 -20
  196. package/dist/cjs/plugins/placeholder-text/placeholder-text-nodeview.js +0 -89
  197. package/dist/cjs/plugins/placeholder-text/plugin-key.js +0 -8
  198. package/dist/cjs/plugins/placeholder-text/plugin.js +0 -267
  199. package/dist/cjs/plugins/placeholder-text/selection-utils.js +0 -14
  200. package/dist/cjs/plugins/placeholder-text/styles.js +0 -13
  201. package/dist/cjs/plugins/placeholder-text/types.js +0 -5
  202. package/dist/cjs/plugins/placeholder-text/ui/FloatingToolbar/index.js +0 -86
  203. package/dist/cjs/plugins/placeholder-text/ui/FloatingToolbar/styles.js +0 -15
  204. package/dist/cjs/plugins/placeholder-text/ui/FloatingToolbar/utils.js +0 -54
  205. package/dist/cjs/plugins/placeholder-text/ui/PlaceholderFloatingToolbar/index.js +0 -89
  206. package/dist/es2019/plugins/placeholder-text/actions.js +0 -27
  207. package/dist/es2019/plugins/placeholder-text/fake-text-cursor/cursor.js +0 -77
  208. package/dist/es2019/plugins/placeholder-text/index.js +0 -2
  209. package/dist/es2019/plugins/placeholder-text/placeholder-text-nodeview.js +0 -77
  210. package/dist/es2019/plugins/placeholder-text/plugin-key.js +0 -2
  211. package/dist/es2019/plugins/placeholder-text/plugin.js +0 -247
  212. package/dist/es2019/plugins/placeholder-text/selection-utils.js +0 -8
  213. package/dist/es2019/plugins/placeholder-text/styles.js +0 -52
  214. package/dist/es2019/plugins/placeholder-text/types.js +0 -1
  215. package/dist/es2019/plugins/placeholder-text/ui/FloatingToolbar/index.js +0 -45
  216. package/dist/es2019/plugins/placeholder-text/ui/FloatingToolbar/styles.js +0 -15
  217. package/dist/es2019/plugins/placeholder-text/ui/FloatingToolbar/utils.js +0 -41
  218. package/dist/es2019/plugins/placeholder-text/ui/PlaceholderFloatingToolbar/index.js +0 -60
  219. package/dist/esm/plugins/placeholder-text/actions.js +0 -29
  220. package/dist/esm/plugins/placeholder-text/fake-text-cursor/cursor.js +0 -100
  221. package/dist/esm/plugins/placeholder-text/index.js +0 -2
  222. package/dist/esm/plugins/placeholder-text/placeholder-text-nodeview.js +0 -82
  223. package/dist/esm/plugins/placeholder-text/plugin-key.js +0 -2
  224. package/dist/esm/plugins/placeholder-text/plugin.js +0 -259
  225. package/dist/esm/plugins/placeholder-text/selection-utils.js +0 -8
  226. package/dist/esm/plugins/placeholder-text/styles.js +0 -6
  227. package/dist/esm/plugins/placeholder-text/types.js +0 -1
  228. package/dist/esm/plugins/placeholder-text/ui/FloatingToolbar/index.js +0 -63
  229. package/dist/esm/plugins/placeholder-text/ui/FloatingToolbar/styles.js +0 -8
  230. package/dist/esm/plugins/placeholder-text/ui/FloatingToolbar/utils.js +0 -48
  231. package/dist/esm/plugins/placeholder-text/ui/PlaceholderFloatingToolbar/index.js +0 -79
  232. package/dist/types/plugins/placeholder-text/actions.d.ts +0 -4
  233. package/dist/types/plugins/placeholder-text/fake-text-cursor/cursor.d.ts +0 -30
  234. package/dist/types/plugins/placeholder-text/index.d.ts +0 -3
  235. package/dist/types/plugins/placeholder-text/placeholder-text-nodeview.d.ts +0 -17
  236. package/dist/types/plugins/placeholder-text/plugin-key.d.ts +0 -3
  237. package/dist/types/plugins/placeholder-text/plugin.d.ts +0 -7
  238. package/dist/types/plugins/placeholder-text/selection-utils.d.ts +0 -2
  239. package/dist/types/plugins/placeholder-text/styles.d.ts +0 -1
  240. package/dist/types/plugins/placeholder-text/types.d.ts +0 -18
  241. package/dist/types/plugins/placeholder-text/ui/FloatingToolbar/index.d.ts +0 -28
  242. package/dist/types/plugins/placeholder-text/ui/FloatingToolbar/styles.d.ts +0 -1
  243. package/dist/types/plugins/placeholder-text/ui/FloatingToolbar/utils.d.ts +0 -13
  244. package/dist/types/plugins/placeholder-text/ui/PlaceholderFloatingToolbar/index.d.ts +0 -25
  245. package/dist/types-ts4.5/plugins/placeholder-text/actions.d.ts +0 -4
  246. package/dist/types-ts4.5/plugins/placeholder-text/fake-text-cursor/cursor.d.ts +0 -30
  247. package/dist/types-ts4.5/plugins/placeholder-text/index.d.ts +0 -3
  248. package/dist/types-ts4.5/plugins/placeholder-text/placeholder-text-nodeview.d.ts +0 -17
  249. package/dist/types-ts4.5/plugins/placeholder-text/plugin-key.d.ts +0 -3
  250. package/dist/types-ts4.5/plugins/placeholder-text/plugin.d.ts +0 -7
  251. package/dist/types-ts4.5/plugins/placeholder-text/selection-utils.d.ts +0 -2
  252. package/dist/types-ts4.5/plugins/placeholder-text/styles.d.ts +0 -1
  253. package/dist/types-ts4.5/plugins/placeholder-text/types.d.ts +0 -18
  254. package/dist/types-ts4.5/plugins/placeholder-text/ui/FloatingToolbar/index.d.ts +0 -28
  255. package/dist/types-ts4.5/plugins/placeholder-text/ui/FloatingToolbar/styles.d.ts +0 -1
  256. package/dist/types-ts4.5/plugins/placeholder-text/ui/FloatingToolbar/utils.d.ts +0 -13
  257. package/dist/types-ts4.5/plugins/placeholder-text/ui/PlaceholderFloatingToolbar/index.d.ts +0 -25
  258. /package/dist/cjs/{plugins/panel/styles.js → ui/ContentStyles/panel.js} +0 -0
  259. /package/dist/es2019/{plugins/panel/styles.js → ui/ContentStyles/panel.js} +0 -0
  260. /package/dist/esm/{plugins/panel/styles.js → ui/ContentStyles/panel.js} +0 -0
@@ -1,77 +0,0 @@
1
- import { Selection } from '@atlaskit/editor-prosemirror/state';
2
- import { browser, ZERO_WIDTH_SPACE } from '@atlaskit/editor-common/utils';
3
- const serializePlaceholderNode = node => {
4
- const element = document.createElement('span');
5
- element.classList.add('pm-placeholder');
6
-
7
- // the inline node api test suite requires the following class name
8
- element.classList.add('placeholderView-content-wrap');
9
- element.innerText = ZERO_WIDTH_SPACE;
10
- const elementChildren = document.createElement('span');
11
- elementChildren.classList.add('pm-placeholder__text');
12
- elementChildren.dataset.placeholder = node.attrs.text;
13
- elementChildren.setAttribute('contenteditable', 'false');
14
- element.appendChild(elementChildren);
15
- if (browser.safari) {
16
- element.appendChild(document.createTextNode(ZERO_WIDTH_SPACE));
17
- } else {
18
- element.appendChild(document.createElement('wbr'));
19
- }
20
- return element;
21
- };
22
- export class PlaceholderTextNodeView {
23
- constructor(node, view, getPos) {
24
- this.node = node;
25
- this.view = view;
26
- this.getPos = getPos;
27
- this.dom = serializePlaceholderNode(this.node);
28
- this.getPos = getPos;
29
- }
30
- stopEvent(e) {
31
- if (e.type === 'mousedown' && typeof this.getPos === 'function') {
32
- e.preventDefault();
33
- const {
34
- view
35
- } = this;
36
- const startNodePosition = this.getPos();
37
- if (typeof startNodePosition !== 'number') {
38
- return false;
39
- }
40
- const tr = view.state.tr;
41
- tr.setSelection(Selection.near(tr.doc.resolve(startNodePosition)));
42
- view.dispatch(tr);
43
- return true;
44
- }
45
- return false;
46
- }
47
- ignoreMutation(record) {
48
- if (typeof this.getPos !== 'function' || record.type !== 'selection') {
49
- return true;
50
- }
51
- const {
52
- view,
53
- node
54
- } = this;
55
- const placeholderStartPosition = this.getPos();
56
- if (typeof placeholderStartPosition !== 'number') {
57
- return false;
58
- }
59
- const placeholderEndPosition = placeholderStartPosition + node.nodeSize;
60
- const selection = view.state.selection;
61
-
62
- // when the selection is set right after the placeholder.
63
- // we should let ProseMirror deal with this edge-case
64
- if (selection.from === placeholderEndPosition) {
65
- return false;
66
- }
67
- const isSelectionAtPlaceholder = selection.from === placeholderStartPosition;
68
- const isSelectionAfterlaceholder = selection.from > placeholderEndPosition;
69
- if (isSelectionAtPlaceholder || isSelectionAfterlaceholder) {
70
- const tr = view.state.tr;
71
- tr.setSelection(Selection.near(tr.doc.resolve(placeholderEndPosition)));
72
- view.dispatch(tr);
73
- return true;
74
- }
75
- return true;
76
- }
77
- }
@@ -1,2 +0,0 @@
1
- import { PluginKey } from '@atlaskit/editor-prosemirror/state';
2
- export const pluginKey = new PluginKey('placeholderTextPlugin');
@@ -1,247 +0,0 @@
1
- import React from 'react';
2
- import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
3
- import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
4
- import { placeholder } from '@atlaskit/adf-schema';
5
- import MediaServicesTextIcon from '@atlaskit/icon/glyph/media-services/text';
6
- import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
7
- import { isNodeEmpty } from '@atlaskit/editor-common/utils';
8
- import { drawFakeTextCursor, FakeTextCursorSelection } from './fake-text-cursor/cursor';
9
- import PlaceholderFloatingToolbar from './ui/PlaceholderFloatingToolbar';
10
- import { hidePlaceholderFloatingToolbar, insertPlaceholderTextAtSelection } from './actions';
11
- import { PlaceholderTextNodeView } from './placeholder-text-nodeview';
12
- import { pluginKey } from './plugin-key';
13
- import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
14
- import { toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/messages';
15
- import { isSelectionAtPlaceholder } from './selection-utils';
16
- const getOpenTypeAhead = (trigger, api) => {
17
- var _api$typeAhead, _api$typeAhead$action, _api$typeAhead2, _api$typeAhead2$actio;
18
- const typeAheadHandler = api === null || api === void 0 ? void 0 : (_api$typeAhead = api.typeAhead) === null || _api$typeAhead === void 0 ? void 0 : (_api$typeAhead$action = _api$typeAhead.actions) === null || _api$typeAhead$action === void 0 ? void 0 : _api$typeAhead$action.findHandlerByTrigger(trigger);
19
- if (!typeAheadHandler || !typeAheadHandler.id) {
20
- return null;
21
- }
22
- return api === null || api === void 0 ? void 0 : (_api$typeAhead2 = api.typeAhead) === null || _api$typeAhead2 === void 0 ? void 0 : (_api$typeAhead2$actio = _api$typeAhead2.actions) === null || _api$typeAhead2$actio === void 0 ? void 0 : _api$typeAhead2$actio.openAtTransaction({
23
- triggerHandler: typeAheadHandler,
24
- inputMethod: INPUT_METHOD.KEYBOARD
25
- });
26
- };
27
- export function createPlugin(dispatch, options, api) {
28
- const allowInserting = !!options.allowInserting;
29
- return new SafePlugin({
30
- key: pluginKey,
31
- state: {
32
- init: () => ({
33
- showInsertPanelAt: null,
34
- allowInserting
35
- }),
36
- apply: (tr, state) => {
37
- const meta = tr.getMeta(pluginKey);
38
- if (meta && meta.showInsertPanelAt !== undefined) {
39
- const newState = {
40
- showInsertPanelAt: meta.showInsertPanelAt,
41
- allowInserting
42
- };
43
- dispatch(pluginKey, newState);
44
- return newState;
45
- } else if (state.showInsertPanelAt) {
46
- const newState = {
47
- showInsertPanelAt: tr.mapping.map(state.showInsertPanelAt),
48
- allowInserting
49
- };
50
- dispatch(pluginKey, newState);
51
- return newState;
52
- }
53
- return state;
54
- }
55
- },
56
- appendTransaction(transactions, oldState, newState) {
57
- if (transactions.some(txn => txn.docChanged)) {
58
- const didPlaceholderExistBeforeTxn = oldState.selection.$head.nodeAfter === newState.selection.$head.nodeAfter;
59
- const adjacentNode = newState.selection.$head.nodeAfter;
60
- const adjacentNodePos = newState.selection.$head.pos;
61
- const placeholderNodeType = newState.schema.nodes.placeholder;
62
- if (adjacentNode && adjacentNode.type === placeholderNodeType && didPlaceholderExistBeforeTxn) {
63
- var _$newHead$nodeBefore;
64
- const {
65
- $head: $newHead
66
- } = newState.selection;
67
- const {
68
- $head: $oldHead
69
- } = oldState.selection;
70
- // Check that cursor has moved forward in the document **and** that there is content before the cursor
71
- const cursorMoved = $oldHead.pos < $newHead.pos;
72
- const nodeBeforeHasContent = !isNodeEmpty($newHead.nodeBefore);
73
- const nodeBeforeIsInline = (_$newHead$nodeBefore = $newHead.nodeBefore) === null || _$newHead$nodeBefore === void 0 ? void 0 : _$newHead$nodeBefore.type.isInline;
74
- if (cursorMoved && (nodeBeforeHasContent || nodeBeforeIsInline)) {
75
- const {
76
- $from,
77
- $to
78
- } = NodeSelection.create(newState.doc, adjacentNodePos);
79
- return newState.tr.deleteRange($from.pos, $to.pos);
80
- }
81
- }
82
- }
83
-
84
- // Handle Fake Text Cursor for Floating Toolbar
85
- if (!pluginKey.getState(oldState).showInsertPanelAt && pluginKey.getState(newState).showInsertPanelAt) {
86
- return newState.tr.setSelection(new FakeTextCursorSelection(newState.selection.$from));
87
- }
88
- if (pluginKey.getState(oldState).showInsertPanelAt && !pluginKey.getState(newState).showInsertPanelAt) {
89
- if (newState.selection instanceof FakeTextCursorSelection) {
90
- return newState.tr.setSelection(new TextSelection(newState.selection.$from));
91
- }
92
- }
93
- return;
94
- },
95
- props: {
96
- decorations: drawFakeTextCursor,
97
- handleDOMEvents: {
98
- beforeinput: (view, event) => {
99
- const {
100
- state
101
- } = view;
102
- if (event instanceof InputEvent && !event.isComposing && event.inputType === 'insertText' && isSelectionAtPlaceholder(view.state.selection)) {
103
- event.stopPropagation();
104
- event.preventDefault();
105
- const startNodePosition = state.selection.from;
106
- const content = event.data || '';
107
- const tr = view.state.tr;
108
- tr.delete(startNodePosition, startNodePosition + 1);
109
- const openTypeAhead = getOpenTypeAhead(content, api);
110
- if (openTypeAhead) {
111
- openTypeAhead(tr);
112
- } else {
113
- tr.insertText(content);
114
- }
115
- view.dispatch(tr);
116
- return true;
117
- }
118
- return false;
119
- }
120
- },
121
- nodeViews: {
122
- placeholder: (node, view, getPos) => new PlaceholderTextNodeView(node, view, getPos)
123
- }
124
- }
125
- });
126
- }
127
- function ContentComponent({
128
- editorView,
129
- dependencyApi,
130
- popupsMountPoint,
131
- popupsBoundariesElement
132
- }) {
133
- const {
134
- placeholderTextState
135
- } = useSharedPluginState(dependencyApi, ['placeholderText']);
136
- const insertPlaceholderText = value => insertPlaceholderTextAtSelection(value)(editorView.state, editorView.dispatch);
137
- const hidePlaceholderToolbar = () => hidePlaceholderFloatingToolbar(editorView.state, editorView.dispatch);
138
- const getNodeFromPos = pos => editorView.domAtPos(pos).node;
139
- const getFixedCoordinatesFromPos = pos => editorView.coordsAtPos(pos);
140
- const setFocusInEditor = () => editorView.focus();
141
- if (placeholderTextState !== null && placeholderTextState !== void 0 && placeholderTextState.showInsertPanelAt) {
142
- return /*#__PURE__*/React.createElement(PlaceholderFloatingToolbar, {
143
- editorViewDOM: editorView.dom,
144
- popupsMountPoint: popupsMountPoint,
145
- popupsBoundariesElement: popupsBoundariesElement,
146
- getFixedCoordinatesFromPos: getFixedCoordinatesFromPos,
147
- getNodeFromPos: getNodeFromPos,
148
- hidePlaceholderFloatingToolbar: hidePlaceholderToolbar,
149
- showInsertPanelAt: placeholderTextState.showInsertPanelAt,
150
- insertPlaceholder: insertPlaceholderText,
151
- setFocusInEditor: setFocusInEditor
152
- });
153
- }
154
- return null;
155
- }
156
- const basePlaceholderTextPlugin = ({
157
- api,
158
- config: options
159
- }) => ({
160
- name: 'placeholderText',
161
- nodes() {
162
- return [{
163
- name: 'placeholder',
164
- node: placeholder
165
- }];
166
- },
167
- pmPlugins() {
168
- return [{
169
- name: 'placeholderText',
170
- plugin: ({
171
- dispatch
172
- }) => createPlugin(dispatch, options, api)
173
- }];
174
- },
175
- getSharedState(editorState) {
176
- if (!editorState) {
177
- return undefined;
178
- }
179
- const {
180
- showInsertPanelAt,
181
- allowInserting
182
- } = pluginKey.getState(editorState) || {
183
- showInsertPanelAt: null
184
- };
185
- return {
186
- showInsertPanelAt,
187
- allowInserting: !!allowInserting
188
- };
189
- },
190
- contentComponent({
191
- editorView,
192
- popupsMountPoint,
193
- popupsBoundariesElement
194
- }) {
195
- return /*#__PURE__*/React.createElement(ContentComponent, {
196
- editorView: editorView,
197
- popupsMountPoint: popupsMountPoint,
198
- popupsBoundariesElement: popupsBoundariesElement,
199
- dependencyApi: api
200
- });
201
- }
202
- });
203
- const decorateWithPluginOptions = (plugin, options, api) => {
204
- if (!options.allowInserting) {
205
- return plugin;
206
- }
207
- plugin.pluginsOptions = {
208
- quickInsert: ({
209
- formatMessage
210
- }) => [{
211
- id: 'placeholderText',
212
- title: formatMessage(messages.placeholderText),
213
- description: formatMessage(messages.placeholderTextDescription),
214
- priority: 1400,
215
- keywords: ['placeholder'],
216
- icon: () => /*#__PURE__*/React.createElement(MediaServicesTextIcon, {
217
- label: ""
218
- }),
219
- action(insert, state) {
220
- var _api$analytics;
221
- const tr = state.tr;
222
- tr.setMeta(pluginKey, {
223
- showInsertPanelAt: tr.selection.anchor
224
- });
225
- api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions.attachAnalyticsEvent({
226
- action: ACTION.INSERTED,
227
- actionSubject: ACTION_SUBJECT.DOCUMENT,
228
- actionSubjectId: ACTION_SUBJECT_ID.PLACEHOLDER_TEXT,
229
- attributes: {
230
- inputMethod: INPUT_METHOD.QUICK_INSERT
231
- },
232
- eventType: EVENT_TYPE.TRACK
233
- })(tr);
234
- return tr;
235
- }
236
- }]
237
- };
238
- return plugin;
239
- };
240
- const placeholderTextPlugin = ({
241
- config: options = {},
242
- api
243
- }) => decorateWithPluginOptions(basePlaceholderTextPlugin({
244
- config: options,
245
- api
246
- }), options, api);
247
- export default placeholderTextPlugin;
@@ -1,8 +0,0 @@
1
- import { TextSelection } from '@atlaskit/editor-prosemirror/state';
2
- export const isSelectionAtPlaceholder = selection => {
3
- if (!(selection instanceof TextSelection) || !selection.$cursor) {
4
- return false;
5
- }
6
- const node = selection.$cursor.doc.nodeAt(selection.$cursor.pos);
7
- return (node === null || node === void 0 ? void 0 : node.type.name) === 'placeholder';
8
- };
@@ -1,52 +0,0 @@
1
- import { css } from '@emotion/react';
2
- import { B75, N200 } from '@atlaskit/theme/colors';
3
- import { SelectionStyle, getSelectionStyles, akEditorSelectedNodeClassName } from '@atlaskit/editor-shared-styles';
4
- export const placeholderTextStyles = css`
5
- .ProseMirror span[data-placeholder] {
6
- color: ${`var(--ds-text-subtlest, ${N200})`};
7
- display: inline;
8
- }
9
-
10
- .ProseMirror span.pm-placeholder {
11
- display: inline;
12
- color: ${`var(--ds-text-subtlest, ${N200})`};
13
- }
14
- .ProseMirror span.pm-placeholder__text {
15
- display: inline;
16
- color: ${`var(--ds-text-subtlest, ${N200})`};
17
- }
18
-
19
- .ProseMirror span.pm-placeholder.${akEditorSelectedNodeClassName} {
20
- ${getSelectionStyles([SelectionStyle.Background])}
21
- }
22
-
23
- .ProseMirror span.pm-placeholder__text[data-placeholder]::after {
24
- color: ${`var(--ds-text-subtlest, ${N200})`};
25
- cursor: text;
26
- content: attr(data-placeholder);
27
- display: inline;
28
- }
29
-
30
- .ProseMirror {
31
- .ProseMirror-fake-text-cursor {
32
- display: inline;
33
- pointer-events: none;
34
- position: relative;
35
- }
36
-
37
- .ProseMirror-fake-text-cursor::after {
38
- content: '';
39
- display: inline;
40
- top: 0;
41
- position: absolute;
42
- border-right: 1px solid ${"var(--ds-border, rgba(0, 0, 0, 0.4))"};
43
- }
44
-
45
- .ProseMirror-fake-text-selection {
46
- display: inline;
47
- pointer-events: none;
48
- position: relative;
49
- background-color: ${`var(--ds-background-selected, ${B75})`};
50
- }
51
- }
52
- `;
@@ -1 +0,0 @@
1
- export {};
@@ -1,45 +0,0 @@
1
- /** @jsx jsx */
2
- import { jsx } from '@emotion/react';
3
- import { PureComponent } from 'react';
4
- import { Popup } from '@atlaskit/editor-common/ui';
5
- import { container } from './styles';
6
- export { handlePositionCalculatedWith, getOffsetParent, getNearestNonTextNode } from './utils';
7
- export default class FloatingToolbar extends PureComponent {
8
- render() {
9
- const {
10
- children,
11
- target,
12
- offset,
13
- fitWidth,
14
- fitHeight = 40,
15
- onPositionCalculated,
16
- popupsMountPoint,
17
- popupsBoundariesElement,
18
- className,
19
- absoluteOffset,
20
- alignX,
21
- alignY,
22
- zIndex
23
- } = this.props;
24
- if (!target) {
25
- return null;
26
- }
27
- return jsx(Popup, {
28
- absoluteOffset: absoluteOffset,
29
- alignX: alignX,
30
- alignY: alignY,
31
- target: target,
32
- zIndex: zIndex,
33
- mountTo: popupsMountPoint,
34
- boundariesElement: popupsBoundariesElement,
35
- offset: offset,
36
- fitWidth: fitWidth,
37
- fitHeight: fitHeight,
38
- onPositionCalculated: onPositionCalculated
39
- }, jsx("div", {
40
- css: container(fitHeight),
41
- "data-testid": "popup-container",
42
- className: className
43
- }, children));
44
- }
45
- }
@@ -1,15 +0,0 @@
1
- import { css } from '@emotion/react';
2
- import { borderRadius } from '@atlaskit/theme/constants';
3
- import { N0, N50A, N60A } from '@atlaskit/theme/colors';
4
- export const container = height => css`
5
- border-radius: ${borderRadius()}px;
6
- box-shadow: ${`var(--ds-shadow-overlay, ${`0 12px 24px -6px ${N50A}, 0 0 1px ${N60A}`})`};
7
- display: flex;
8
- align-items: center;
9
- box-sizing: border-box;
10
- padding: ${"var(--ds-space-050, 4px)"} ${"var(--ds-space-100, 8px)"};
11
- background-color: ${`var(--ds-background-input, ${N0})`};
12
- ${height ? css`
13
- height: ${height}px;
14
- ` : ''};
15
- `;
@@ -1,41 +0,0 @@
1
- const getCursorHeightFrom = node => parseFloat(window.getComputedStyle(node, undefined).lineHeight || '');
2
- export const getOffsetParent = (editorViewDom, popupsMountPoint) => popupsMountPoint ? popupsMountPoint.offsetParent : editorViewDom.offsetParent;
3
- export const getNearestNonTextNode = node => node.nodeType === Node.TEXT_NODE ? node.parentNode : node;
4
-
5
- /**
6
- * We need to translate the co-ordinates because `coordsAtPos` returns co-ordinates
7
- * relative to `window`. And, also need to adjust the cursor container height.
8
- * (0, 0)
9
- * +--------------------- [window] ---------------------+
10
- * | (left, top) +-------- [Offset Parent] --------+ |
11
- * | {coordsAtPos} | [Cursor] <- cursorHeight | |
12
- * | | [FloatingToolbar] | |
13
- */
14
- const convertFixedCoordinatesToAbsolutePositioning = (coordinates, offsetParent, cursorHeight) => {
15
- const {
16
- left: offsetParentLeft,
17
- top: offsetParentTop,
18
- height: offsetParentHeight
19
- } = offsetParent.getBoundingClientRect();
20
- return {
21
- left: coordinates.left - offsetParentLeft,
22
- right: coordinates.right - offsetParentLeft,
23
- top: coordinates.top - (offsetParentTop - cursorHeight) + offsetParent.scrollTop,
24
- bottom: offsetParentHeight - (coordinates.top - (offsetParentTop - cursorHeight) - offsetParent.scrollTop)
25
- };
26
- };
27
- export const handlePositionCalculatedWith = (offsetParent, node, getCurrentFixedCoordinates) => position => {
28
- if (!offsetParent) {
29
- return position;
30
- }
31
- const target = getNearestNonTextNode(node);
32
- const cursorHeight = getCursorHeightFrom(target);
33
- const fixedCoordinates = getCurrentFixedCoordinates();
34
- const absoluteCoordinates = convertFixedCoordinatesToAbsolutePositioning(fixedCoordinates, offsetParent, cursorHeight);
35
- return {
36
- left: position.left ? absoluteCoordinates.left : undefined,
37
- right: position.right ? absoluteCoordinates.right : undefined,
38
- top: position.top ? absoluteCoordinates.top : undefined,
39
- bottom: position.bottom ? absoluteCoordinates.bottom : undefined
40
- };
41
- };
@@ -1,60 +0,0 @@
1
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
- import React from 'react';
3
- import { defineMessages, injectIntl } from 'react-intl-next';
4
- import { PanelTextInput } from '@atlaskit/editor-common/ui';
5
- import FloatingToolbar, { handlePositionCalculatedWith, getOffsetParent, getNearestNonTextNode } from '../FloatingToolbar';
6
- export const messages = defineMessages({
7
- placeholderTextPlaceholder: {
8
- id: 'fabric.editor.placeholderTextPlaceholder',
9
- defaultMessage: 'Add placeholder text',
10
- description: ''
11
- }
12
- });
13
- class PlaceholderFloatingToolbar extends React.Component {
14
- constructor(...args) {
15
- super(...args);
16
- _defineProperty(this, "handleSubmit", value => {
17
- if (value) {
18
- this.props.insertPlaceholder(value);
19
- this.props.setFocusInEditor();
20
- } else {
21
- this.props.hidePlaceholderFloatingToolbar();
22
- }
23
- });
24
- _defineProperty(this, "handleBlur", () => {
25
- this.props.hidePlaceholderFloatingToolbar();
26
- });
27
- }
28
- render() {
29
- const {
30
- getNodeFromPos,
31
- showInsertPanelAt,
32
- editorViewDOM,
33
- popupsMountPoint,
34
- getFixedCoordinatesFromPos,
35
- popupsBoundariesElement,
36
- intl: {
37
- formatMessage
38
- }
39
- } = this.props;
40
- const target = getNodeFromPos(showInsertPanelAt);
41
- const offsetParent = getOffsetParent(editorViewDOM, popupsMountPoint);
42
- const getFixedCoordinates = () => getFixedCoordinatesFromPos(showInsertPanelAt);
43
- const handlePositionCalculated = handlePositionCalculatedWith(offsetParent, target, getFixedCoordinates);
44
- return /*#__PURE__*/React.createElement(FloatingToolbar, {
45
- target: getNearestNonTextNode(target),
46
- onPositionCalculated: handlePositionCalculated,
47
- popupsMountPoint: popupsMountPoint,
48
- popupsBoundariesElement: popupsBoundariesElement,
49
- fitHeight: 32,
50
- offset: [0, 12]
51
- }, /*#__PURE__*/React.createElement(PanelTextInput, {
52
- placeholder: formatMessage(messages.placeholderTextPlaceholder),
53
- onSubmit: this.handleSubmit,
54
- onBlur: this.handleBlur,
55
- autoFocus: true,
56
- width: 300
57
- }));
58
- }
59
- }
60
- export default injectIntl(PlaceholderFloatingToolbar);
@@ -1,29 +0,0 @@
1
- import { pluginKey } from './plugin-key';
2
- export var showPlaceholderFloatingToolbar = function showPlaceholderFloatingToolbar(state, dispatch) {
3
- var tr = state.tr;
4
- if (!state.selection.empty) {
5
- tr.deleteSelection();
6
- }
7
- tr.setMeta(pluginKey, {
8
- showInsertPanelAt: tr.selection.anchor
9
- });
10
- tr.scrollIntoView();
11
- dispatch(tr);
12
- return true;
13
- };
14
- export var insertPlaceholderTextAtSelection = function insertPlaceholderTextAtSelection(value) {
15
- return function (state, dispatch) {
16
- dispatch(state.tr.replaceSelectionWith(state.schema.nodes.placeholder.createChecked({
17
- text: value
18
- })).setMeta(pluginKey, {
19
- showInsertPanelAt: null
20
- }).scrollIntoView());
21
- return true;
22
- };
23
- };
24
- export var hidePlaceholderFloatingToolbar = function hidePlaceholderFloatingToolbar(state, dispatch) {
25
- dispatch(state.tr.setMeta(pluginKey, {
26
- showInsertPanelAt: null
27
- }));
28
- return true;
29
- };
@@ -1,100 +0,0 @@
1
- import _inherits from "@babel/runtime/helpers/inherits";
2
- import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
3
- import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
4
- import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
5
- import _createClass from "@babel/runtime/helpers/createClass";
6
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
7
- 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); }; }
8
- 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; } }
9
- import { TextSelection, Selection } from '@atlaskit/editor-prosemirror/state';
10
- import { Decoration, DecorationSet } from '@atlaskit/editor-prosemirror/view';
11
- import { Slice } from '@atlaskit/editor-prosemirror/model';
12
- export var FakeTextCursorBookmark = /*#__PURE__*/function () {
13
- function FakeTextCursorBookmark(pos) {
14
- _classCallCheck(this, FakeTextCursorBookmark);
15
- _defineProperty(this, "pos", undefined);
16
- _defineProperty(this, "visible", false);
17
- this.pos = pos;
18
- }
19
- _createClass(FakeTextCursorBookmark, [{
20
- key: "map",
21
- value: function map(mapping) {
22
- return new FakeTextCursorBookmark(mapping.map(this.pos));
23
- }
24
- }, {
25
- key: "resolve",
26
- value: function resolve(doc) {
27
- var $pos = doc.resolve(this.pos);
28
- return Selection.near($pos);
29
- }
30
- }]);
31
- return FakeTextCursorBookmark;
32
- }();
33
- export var FakeTextCursorSelection = /*#__PURE__*/function (_Selection) {
34
- _inherits(FakeTextCursorSelection, _Selection);
35
- var _super = _createSuper(FakeTextCursorSelection);
36
- function FakeTextCursorSelection($pos) {
37
- _classCallCheck(this, FakeTextCursorSelection);
38
- return _super.call(this, $pos, $pos);
39
- }
40
- _createClass(FakeTextCursorSelection, [{
41
- key: "map",
42
- value: function map(doc, mapping) {
43
- var $pos = doc.resolve(mapping.map(this.$head.pos));
44
- return new FakeTextCursorSelection($pos);
45
- }
46
- }, {
47
- key: "eq",
48
- value: function eq(other) {
49
- return other instanceof FakeTextCursorSelection && other.head === this.head;
50
- }
51
- }, {
52
- key: "toJSON",
53
- value: function toJSON() {
54
- return {
55
- type: 'Cursor',
56
- pos: this.head
57
- };
58
- }
59
- }, {
60
- key: "getBookmark",
61
- value: function getBookmark() {
62
- return new FakeTextCursorBookmark(this.anchor);
63
- }
64
- }], [{
65
- key: "content",
66
- value: function content() {
67
- return Slice.empty;
68
- }
69
- }, {
70
- key: "fromJSON",
71
- value: function fromJSON(doc, json) {
72
- return new FakeTextCursorSelection(doc.resolve(json.pos));
73
- }
74
- }]);
75
- return FakeTextCursorSelection;
76
- }(Selection);
77
- Selection.jsonID('fake-text-cursor', FakeTextCursorSelection);
78
- export var addFakeTextCursor = function addFakeTextCursor(state, dispatch) {
79
- var selection = state.selection;
80
- if (selection.empty) {
81
- var $from = state.selection.$from;
82
- dispatch(state.tr.setSelection(new FakeTextCursorSelection($from)));
83
- }
84
- };
85
- export var removeFakeTextCursor = function removeFakeTextCursor(state, dispatch) {
86
- if (state.selection instanceof FakeTextCursorSelection) {
87
- var $from = state.selection.$from;
88
- dispatch(state.tr.setSelection(new TextSelection($from)));
89
- }
90
- };
91
- export var drawFakeTextCursor = function drawFakeTextCursor(state) {
92
- if (!(state.selection instanceof FakeTextCursorSelection)) {
93
- return null;
94
- }
95
- var node = document.createElement('div');
96
- node.className = 'ProseMirror-fake-text-cursor';
97
- return DecorationSet.create(state.doc, [Decoration.widget(state.selection.head, node, {
98
- key: 'Cursor'
99
- })]);
100
- };