@modusoperandi/licit 0.1.9 → 0.13.2

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 (340) hide show
  1. package/.github/workflows/build.yml +1 -7
  2. package/.github/workflows/lint.yml +1 -1
  3. package/README.md +1 -1
  4. package/babel.config.json +54 -0
  5. package/dist/BlockquoteNodeSpec.js +2 -2
  6. package/dist/CZIProseMirror.js +4 -4
  7. package/dist/CodeBlockCommand.js +2 -2
  8. package/dist/CodeBlockCommand.js.flow +1 -1
  9. package/dist/CursorPlaceholderPlugin.js +2 -2
  10. package/dist/DocLayoutCommand.js +2 -4
  11. package/dist/DocLayoutCommand.js.flow +1 -1
  12. package/dist/DocNodeSpec.js +1 -1
  13. package/dist/EditorCommands.js +23 -35
  14. package/dist/EditorCommands.js.flow +7 -7
  15. package/dist/EditorKeyMap.js +3 -3
  16. package/dist/FontTypeMarkSpec.js +1 -1
  17. package/dist/HeadingNodeSpec.js +2 -2
  18. package/dist/ImageSourceCommand.js +2 -4
  19. package/dist/ImageSourceCommand.js.flow +1 -1
  20. package/dist/ImageUploadPlaceholderPlugin.js +1 -1
  21. package/dist/LinkSetURLCommand.js +4 -8
  22. package/dist/LinkSetURLCommand.js.flow +3 -3
  23. package/dist/LinkTooltipPlugin.js +9 -15
  24. package/dist/LinkTooltipPlugin.js.flow +5 -5
  25. package/dist/ListToggleCommand.js +5 -11
  26. package/dist/ListToggleCommand.js.flow +3 -3
  27. package/dist/MarkNames.js +1 -1
  28. package/dist/MarksClearCommand.js +3 -3
  29. package/dist/MarksClearCommand.js.flow +1 -1
  30. package/dist/MathEditCommand.js +2 -2
  31. package/dist/MathEditCommand.js.flow +1 -1
  32. package/dist/ParagraphNodeSpec.js +3 -4
  33. package/dist/ParagraphNodeSpec.js.flow +2 -6
  34. package/dist/ParagraphSpacingCommand.js +3 -3
  35. package/dist/SelectionPlaceholderPlugin.js +2 -2
  36. package/dist/SpacerMarkSpec.js +1 -1
  37. package/dist/TableBackgroundColorCommand.js +3 -7
  38. package/dist/TableBackgroundColorCommand.js.flow +3 -3
  39. package/dist/TableBorderColorCommand.js +3 -7
  40. package/dist/TableBorderColorCommand.js.flow +3 -3
  41. package/dist/TableCellColorCommand.js +3 -7
  42. package/dist/TableCellColorCommand.js.flow +3 -3
  43. package/dist/TableCellMenuPlugin.js +4 -6
  44. package/dist/TableCellMenuPlugin.js.flow +3 -3
  45. package/dist/TableInsertCommand.js +3 -5
  46. package/dist/TableInsertCommand.js.flow +2 -2
  47. package/dist/TableResizePlugin.js +2 -2
  48. package/dist/TextInsertTabSpaceCommand.js +2 -4
  49. package/dist/TextInsertTabSpaceCommand.js.flow +1 -1
  50. package/dist/Types.js +1 -1
  51. package/dist/bom.xml +4970 -4167
  52. package/dist/client/CollabConnector.js +17 -2
  53. package/dist/client/CollabConnector.js.flow +17 -2
  54. package/dist/client/EditorConnection.js +15 -4
  55. package/dist/client/EditorConnection.js.flow +14 -3
  56. package/dist/client/Licit.js +73 -58
  57. package/dist/client/Licit.js.flow +101 -85
  58. package/dist/client/Licit.test.js +18 -17
  59. package/dist/client/Licit.test.js.flow +13 -11
  60. package/dist/client/SimpleConnector.js +4 -2
  61. package/dist/client/SimpleConnector.js.flow +3 -1
  62. package/dist/client/http.js +3 -3
  63. package/dist/convertToCSSPTValue.js +1 -1
  64. package/dist/createEmptyEditorState.js +1 -1
  65. package/dist/index.js +16 -16
  66. package/dist/joinListNode.js +2 -2
  67. package/dist/joinListNode.js.flow +1 -1
  68. package/dist/keymaps.js +2 -2
  69. package/dist/patchStyleElements.js +3 -3
  70. package/dist/patchStyleElements.js.flow +1 -1
  71. package/dist/splitListItem.js +2 -2
  72. package/dist/styles.css +2 -2
  73. package/dist/styles0.css +3 -3
  74. package/dist/toggleBlockquote.js +6 -14
  75. package/dist/toggleBlockquote.js.flow +4 -4
  76. package/dist/toggleCodeBlock.js +4 -10
  77. package/dist/toggleCodeBlock.js.flow +3 -3
  78. package/dist/ui/AlertInfo.js +2 -2
  79. package/dist/ui/CommandButton.js +2 -4
  80. package/dist/ui/CommandButton.js.flow +1 -1
  81. package/dist/ui/CommandMenuButton.js +5 -7
  82. package/dist/ui/CommandMenuButton.js.flow +2 -2
  83. package/dist/ui/CustomMenuItem.js +3 -5
  84. package/dist/ui/CustomMenuItem.js.flow +1 -1
  85. package/dist/ui/CustomNodeView.js +3 -3
  86. package/dist/ui/CustomRadioButton.js +8 -6
  87. package/dist/ui/CustomRadioButton.js.flow +3 -3
  88. package/dist/ui/DocLayoutEditor.js +5 -7
  89. package/dist/ui/DocLayoutEditor.js.flow +2 -2
  90. package/dist/ui/Editor.js +1 -2
  91. package/dist/ui/Editor.js.flow +1 -2
  92. package/dist/ui/EditorFrameset.js +1 -1
  93. package/dist/ui/EditorToolbar.js +4 -4
  94. package/dist/ui/EditorToolbar.js.flow +1 -1
  95. package/dist/ui/EditorToolbarConfig.js +1 -1
  96. package/dist/ui/FontSizeCommandMenuButton.js +3 -3
  97. package/dist/ui/FontSizeCommandMenuButton.js.flow +1 -1
  98. package/dist/ui/FontTypeCommandMenuButton.js +3 -3
  99. package/dist/ui/FontTypeCommandMenuButton.js.flow +1 -1
  100. package/dist/ui/ImageAlignEditor.js +5 -5
  101. package/dist/ui/ImageAlignEditor.js.flow +1 -1
  102. package/dist/ui/ImageInlineEditor.js +5 -5
  103. package/dist/ui/ImageInlineEditor.js.flow +1 -1
  104. package/dist/ui/ImageNodeView.js +5 -7
  105. package/dist/ui/ImageNodeView.js.flow +2 -2
  106. package/dist/ui/ImageResizeBox.js +4 -4
  107. package/dist/ui/ImageResizeBox.js.flow +1 -1
  108. package/dist/ui/ImageURLEditor.js +6 -8
  109. package/dist/ui/ImageURLEditor.js.flow +2 -2
  110. package/dist/ui/ImageUploadEditor.js +3 -5
  111. package/dist/ui/ImageUploadEditor.js.flow +2 -2
  112. package/dist/ui/LinkTooltip.js +4 -4
  113. package/dist/ui/LinkTooltip.js.flow +1 -1
  114. package/dist/ui/LinkURLEditor.js +4 -6
  115. package/dist/ui/LinkURLEditor.js.flow +2 -2
  116. package/dist/ui/ListTypeButton.js +5 -7
  117. package/dist/ui/ListTypeButton.js.flow +2 -2
  118. package/dist/ui/MathEditor.js +4 -6
  119. package/dist/ui/MathEditor.js.flow +2 -2
  120. package/dist/ui/MathInlineEditor.js +7 -9
  121. package/dist/ui/MathInlineEditor.js.flow +2 -2
  122. package/dist/ui/MathNodeView.js +5 -7
  123. package/dist/ui/MathNodeView.js.flow +2 -2
  124. package/dist/ui/ResizeObserver.js +1 -1
  125. package/dist/ui/TableGridSizeEditor.js +7 -9
  126. package/dist/ui/TableGridSizeEditor.js.flow +2 -2
  127. package/dist/ui/czi-link-tooltip.css +1 -1
  128. package/dist/ui/czi-vars.css +1 -45
  129. package/dist/ui/findActiveFontType.js +1 -1
  130. package/dist/ui/htmlElementToRect.js +1 -1
  131. package/dist/ui/isElementFullyVisible.js +2 -2
  132. package/dist/ui/isElementFullyVisible.js.flow +1 -1
  133. package/dist/ui/mathquill-editor/MathQuillEditorSymbols.js +1 -1
  134. package/dist/ui/mathquill-editor/MathQuillEditorSymbolsPanel.js +2 -2
  135. package/dist/ui/mathquill-editor/MathQuillEditorSymbolsPanel.js.flow +1 -1
  136. package/dist/ui/resolveImage.js +3 -3
  137. package/dist/ui/toCSSColor.js +1 -1
  138. package/dist/ui/toCSSLineSpacing.js +1 -36
  139. package/dist/ui/toCSSLineSpacing.js.flow +0 -27
  140. package/flow-typed/@modusoperandilicit-ui-commands.js +5 -0
  141. package/jest.config.js +207 -0
  142. package/lint.sh +0 -0
  143. package/node_modules/prosemirror-utils/LICENSE +13 -0
  144. package/{dist/ui/PopUpTypes.js.flow → node_modules/prosemirror-utils/README.md} +0 -0
  145. package/node_modules/prosemirror-utils/dist/helpers.js +119 -0
  146. package/node_modules/prosemirror-utils/dist/index.js +17 -0
  147. package/node_modules/prosemirror-utils/dist/index.js.map +1 -0
  148. package/node_modules/prosemirror-utils/dist/node.js +106 -0
  149. package/node_modules/prosemirror-utils/dist/selection.js +168 -0
  150. package/node_modules/prosemirror-utils/dist/transforms.js +257 -0
  151. package/node_modules/prosemirror-utils/package.json +81 -0
  152. package/node_modules/prosemirror-utils/typings.d.ts +79 -0
  153. package/package.json +14 -8
  154. package/scripts/build_bin.py +0 -0
  155. package/scripts/ci_check_dist.sh +0 -0
  156. package/src/CodeBlockCommand.js +1 -1
  157. package/src/DocLayoutCommand.js +1 -1
  158. package/src/EditorCommands.js +7 -7
  159. package/src/ImageSourceCommand.js +1 -1
  160. package/src/LinkSetURLCommand.js +3 -3
  161. package/src/LinkTooltipPlugin.js +5 -5
  162. package/src/ListToggleCommand.js +3 -3
  163. package/src/MarksClearCommand.js +1 -1
  164. package/src/MathEditCommand.js +1 -1
  165. package/src/ParagraphNodeSpec.js +2 -6
  166. package/src/TableBackgroundColorCommand.js +3 -3
  167. package/src/TableBorderColorCommand.js +3 -3
  168. package/src/TableCellColorCommand.js +3 -3
  169. package/src/TableCellMenuPlugin.js +3 -3
  170. package/src/TableInsertCommand.js +2 -2
  171. package/src/TextInsertTabSpaceCommand.js +1 -1
  172. package/src/client/CollabConnector.js +17 -2
  173. package/src/client/EditorConnection.js +14 -3
  174. package/src/client/Licit.js +101 -85
  175. package/src/client/Licit.test.js +13 -11
  176. package/src/client/SimpleConnector.js +3 -1
  177. package/src/joinListNode.js +1 -1
  178. package/src/patchStyleElements.js +1 -1
  179. package/src/styles.css +2 -2
  180. package/src/styles0.css +3 -3
  181. package/src/toggleBlockquote.js +4 -4
  182. package/src/toggleCodeBlock.js +3 -3
  183. package/src/ui/CommandButton.js +1 -1
  184. package/src/ui/CommandMenuButton.js +2 -2
  185. package/src/ui/CustomMenuItem.js +1 -1
  186. package/src/ui/CustomRadioButton.js +3 -3
  187. package/src/ui/DocLayoutEditor.js +2 -2
  188. package/src/ui/Editor.js +1 -2
  189. package/src/ui/EditorToolbar.js +1 -1
  190. package/src/ui/FontSizeCommandMenuButton.js +1 -1
  191. package/src/ui/FontTypeCommandMenuButton.js +1 -1
  192. package/src/ui/ImageAlignEditor.js +1 -1
  193. package/src/ui/ImageInlineEditor.js +1 -1
  194. package/src/ui/ImageNodeView.js +2 -2
  195. package/src/ui/ImageResizeBox.js +1 -1
  196. package/src/ui/ImageURLEditor.js +2 -2
  197. package/src/ui/ImageUploadEditor.js +2 -2
  198. package/src/ui/LinkTooltip.js +1 -1
  199. package/src/ui/LinkURLEditor.js +2 -2
  200. package/src/ui/ListTypeButton.js +2 -2
  201. package/src/ui/MathEditor.js +2 -2
  202. package/src/ui/MathInlineEditor.js +2 -2
  203. package/src/ui/MathNodeView.js +2 -2
  204. package/src/ui/TableGridSizeEditor.js +2 -2
  205. package/src/ui/czi-link-tooltip.css +1 -1
  206. package/src/ui/czi-vars.css +1 -45
  207. package/src/ui/isElementFullyVisible.js +1 -1
  208. package/src/ui/mathquill-editor/MathQuillEditorSymbolsPanel.js +1 -1
  209. package/src/ui/toCSSLineSpacing.js +0 -27
  210. package/build_customstyle_server.py +0 -7
  211. package/dist/FontSizeCommand.js +0 -80
  212. package/dist/FontSizeCommand.js.flow +0 -57
  213. package/dist/FontTypeCommand.js +0 -137
  214. package/dist/FontTypeCommand.js.flow +0 -100
  215. package/dist/HeadingCommand.js +0 -65
  216. package/dist/HeadingCommand.js.flow +0 -51
  217. package/dist/IndentCommand.js +0 -57
  218. package/dist/IndentCommand.js.flow +0 -41
  219. package/dist/MarkToggleCommand.js +0 -90
  220. package/dist/MarkToggleCommand.js.flow +0 -66
  221. package/dist/TextAlignCommand.js +0 -151
  222. package/dist/TextAlignCommand.js.flow +0 -122
  223. package/dist/TextColorCommand.js +0 -114
  224. package/dist/TextColorCommand.js.flow +0 -87
  225. package/dist/TextHighlightCommand.js +0 -118
  226. package/dist/TextHighlightCommand.js.flow +0 -91
  227. package/dist/TextLineSpacingCommand.js +0 -177
  228. package/dist/TextLineSpacingCommand.js.flow +0 -157
  229. package/dist/applyMark.js +0 -84
  230. package/dist/applyMark.js.flow +0 -61
  231. package/dist/clearMarks.js +0 -160
  232. package/dist/clearMarks.js.flow +0 -128
  233. package/dist/compareNumber.js +0 -18
  234. package/dist/compareNumber.js.flow +0 -11
  235. package/dist/consolidateListNodes.js +0 -291
  236. package/dist/consolidateListNodes.js.flow +0 -281
  237. package/dist/coverage/lcov-report/block-navigation.js +0 -77
  238. package/dist/coverage/lcov-report/block-navigation.js.flow +0 -79
  239. package/dist/coverage/lcov-report/prettify.js +0 -994
  240. package/dist/coverage/lcov-report/prettify.js.flow +0 -2
  241. package/dist/coverage/lcov-report/sorter.js +0 -187
  242. package/dist/coverage/lcov-report/sorter.js.flow +0 -170
  243. package/dist/findNodesWithSameMark.js +0 -89
  244. package/dist/findNodesWithSameMark.js.flow +0 -89
  245. package/dist/isBulletListNode.js +0 -14
  246. package/dist/isBulletListNode.js.flow +0 -9
  247. package/dist/isInsideListItem.js +0 -19
  248. package/dist/isInsideListItem.js.flow +0 -13
  249. package/dist/isListNode.js +0 -22
  250. package/dist/isListNode.js.flow +0 -13
  251. package/dist/isNodeSelectionForNodeType.js +0 -19
  252. package/dist/isNodeSelectionForNodeType.js.flow +0 -15
  253. package/dist/isOrderedListNode.js +0 -14
  254. package/dist/isOrderedListNode.js.flow +0 -9
  255. package/dist/isTextStyleMarkCommandEnabled.js +0 -59
  256. package/dist/isTextStyleMarkCommandEnabled.js.flow +0 -49
  257. package/dist/noop.js +0 -11
  258. package/dist/noop.js.flow +0 -5
  259. package/dist/toggleHeading.js +0 -135
  260. package/dist/toggleHeading.js.flow +0 -113
  261. package/dist/toggleList.js +0 -431
  262. package/dist/toggleList.js.flow +0 -450
  263. package/dist/transformAndPreserveTextSelection.js +0 -173
  264. package/dist/transformAndPreserveTextSelection.js.flow +0 -151
  265. package/dist/ui/ColorEditor.js +0 -118
  266. package/dist/ui/ColorEditor.js.flow +0 -101
  267. package/dist/ui/CustomButton.js +0 -62
  268. package/dist/ui/CustomButton.js.flow +0 -33
  269. package/dist/ui/PointerSurface.js +0 -173
  270. package/dist/ui/PointerSurface.js.flow +0 -141
  271. package/dist/ui/PopUp.js +0 -129
  272. package/dist/ui/PopUp.js.flow +0 -77
  273. package/dist/ui/PopUpManager.js +0 -266
  274. package/dist/ui/PopUpManager.js.flow +0 -213
  275. package/dist/ui/PopUpPosition.js +0 -156
  276. package/dist/ui/PopUpPosition.js.flow +0 -104
  277. package/dist/ui/PopUpTypes.js +0 -1
  278. package/dist/ui/TooltipSurface.js +0 -99
  279. package/dist/ui/TooltipSurface.js.flow +0 -76
  280. package/dist/ui/clamp.js +0 -18
  281. package/dist/ui/clamp.js.flow +0 -11
  282. package/dist/ui/createPopUp.js +0 -199
  283. package/dist/ui/createPopUp.js.flow +0 -205
  284. package/dist/ui/czi-animations.css +0 -15
  285. package/dist/ui/czi-color-editor.css +0 -56
  286. package/dist/ui/czi-custom-button.css +0 -93
  287. package/dist/ui/czi-pop-up.css +0 -32
  288. package/dist/ui/czi-tooltip-surface.css +0 -45
  289. package/dist/ui/preventEventDefault.js +0 -10
  290. package/dist/ui/preventEventDefault.js.flow +0 -5
  291. package/dist/ui/rects.js +0 -58
  292. package/dist/ui/rects.js.flow +0 -47
  293. package/dist/updateIndentLevel.js +0 -232
  294. package/dist/updateIndentLevel.js.flow +0 -211
  295. package/flow-typed/@molicit-citation.js +0 -5
  296. package/licit/server/customstyles/start.js +0 -184
  297. package/run_customstyle_server.py +0 -20
  298. package/src/FontSizeCommand.js +0 -57
  299. package/src/FontTypeCommand.js +0 -100
  300. package/src/HeadingCommand.js +0 -51
  301. package/src/IndentCommand.js +0 -41
  302. package/src/MarkToggleCommand.js +0 -66
  303. package/src/TextAlignCommand.js +0 -122
  304. package/src/TextColorCommand.js +0 -87
  305. package/src/TextHighlightCommand.js +0 -91
  306. package/src/TextLineSpacingCommand.js +0 -157
  307. package/src/applyMark.js +0 -61
  308. package/src/clearMarks.js +0 -128
  309. package/src/compareNumber.js +0 -11
  310. package/src/consolidateListNodes.js +0 -281
  311. package/src/findNodesWithSameMark.js +0 -89
  312. package/src/isBulletListNode.js +0 -9
  313. package/src/isInsideListItem.js +0 -13
  314. package/src/isListNode.js +0 -13
  315. package/src/isNodeSelectionForNodeType.js +0 -15
  316. package/src/isOrderedListNode.js +0 -9
  317. package/src/isTextStyleMarkCommandEnabled.js +0 -49
  318. package/src/noop.js +0 -5
  319. package/src/toggleHeading.js +0 -113
  320. package/src/toggleList.js +0 -450
  321. package/src/transformAndPreserveTextSelection.js +0 -151
  322. package/src/ui/ColorEditor.js +0 -101
  323. package/src/ui/CustomButton.js +0 -33
  324. package/src/ui/PointerSurface.js +0 -141
  325. package/src/ui/PopUp.js +0 -77
  326. package/src/ui/PopUpManager.js +0 -213
  327. package/src/ui/PopUpPosition.js +0 -104
  328. package/src/ui/PopUpTypes.js +0 -0
  329. package/src/ui/TooltipSurface.js +0 -76
  330. package/src/ui/clamp.js +0 -11
  331. package/src/ui/createPopUp.js +0 -205
  332. package/src/ui/czi-animations.css +0 -15
  333. package/src/ui/czi-color-editor.css +0 -56
  334. package/src/ui/czi-custom-button.css +0 -93
  335. package/src/ui/czi-pop-up.css +0 -32
  336. package/src/ui/czi-tooltip-surface.css +0 -45
  337. package/src/ui/preventEventDefault.js +0 -5
  338. package/src/ui/rects.js +0 -47
  339. package/src/updateIndentLevel.js +0 -211
  340. package/utils/build_customstyle_server.js +0 -72
@@ -0,0 +1,168 @@
1
+ import { Selection } from 'prosemirror-state';
2
+ import { equalNodeType, isNodeSelection } from './helpers';
3
+
4
+ // :: (predicate: (node: ProseMirrorNode) → boolean) → (selection: Selection) → ?{pos: number, start: number, depth: number, node: ProseMirrorNode}
5
+ // Iterates over parent nodes, returning the closest node and its start position `predicate` returns truthy for. `start` points to the start position of the node, `pos` points directly before the node.
6
+ //
7
+ // ```javascript
8
+ // const predicate = node => node.type === schema.nodes.blockquote;
9
+ // const parent = findParentNode(predicate)(selection);
10
+ // ```
11
+ export const findParentNode = predicate => ({ $from }) =>
12
+ findParentNodeClosestToPos($from, predicate);
13
+
14
+ // :: ($pos: ResolvedPos, predicate: (node: ProseMirrorNode) → boolean) → ?{pos: number, start: number, depth: number, node: ProseMirrorNode}
15
+ // Iterates over parent nodes starting from the given `$pos`, returning the closest node and its start position `predicate` returns truthy for. `start` points to the start position of the node, `pos` points directly before the node.
16
+ //
17
+ // ```javascript
18
+ // const predicate = node => node.type === schema.nodes.blockquote;
19
+ // const parent = findParentNodeClosestToPos(state.doc.resolve(5), predicate);
20
+ // ```
21
+ export const findParentNodeClosestToPos = ($pos, predicate) => {
22
+ for (let i = $pos.depth; i > 0; i--) {
23
+ const node = $pos.node(i);
24
+ if (predicate(node)) {
25
+ return {
26
+ pos: i > 0 ? $pos.before(i) : 0,
27
+ start: $pos.start(i),
28
+ depth: i,
29
+ node
30
+ };
31
+ }
32
+ }
33
+ };
34
+
35
+ // :: (predicate: (node: ProseMirrorNode) → boolean, domAtPos: (pos: number) → {node: dom.Node, offset: number}) → (selection: Selection) → ?dom.Node
36
+ // Iterates over parent nodes, returning DOM reference of the closest node `predicate` returns truthy for.
37
+ //
38
+ // ```javascript
39
+ // const domAtPos = view.domAtPos.bind(view);
40
+ // const predicate = node => node.type === schema.nodes.table;
41
+ // const parent = findParentDomRef(predicate, domAtPos)(selection); // <table>
42
+ // ```
43
+ export const findParentDomRef = (predicate, domAtPos) => selection => {
44
+ const parent = findParentNode(predicate)(selection);
45
+ if (parent) {
46
+ return findDomRefAtPos(parent.pos, domAtPos);
47
+ }
48
+ };
49
+
50
+ // :: (predicate: (node: ProseMirrorNode) → boolean) → (selection: Selection) → boolean
51
+ // Checks if there's a parent node `predicate` returns truthy for.
52
+ //
53
+ // ```javascript
54
+ // if (hasParentNode(node => node.type === schema.nodes.table)(selection)) {
55
+ // // ....
56
+ // }
57
+ // ```
58
+ export const hasParentNode = predicate => selection => {
59
+ return !!findParentNode(predicate)(selection);
60
+ };
61
+
62
+ // :: (nodeType: union<NodeType, [NodeType]>) → (selection: Selection) → ?{pos: number, start: number, depth: number, node: ProseMirrorNode}
63
+ // Iterates over parent nodes, returning closest node of a given `nodeType`. `start` points to the start position of the node, `pos` points directly before the node.
64
+ //
65
+ // ```javascript
66
+ // const parent = findParentNodeOfType(schema.nodes.paragraph)(selection);
67
+ // ```
68
+ export const findParentNodeOfType = nodeType => selection => {
69
+ return findParentNode(node => equalNodeType(nodeType, node))(selection);
70
+ };
71
+
72
+ // :: ($pos: ResolvedPos, nodeType: union<NodeType, [NodeType]>) → ?{pos: number, start: number, depth: number, node: ProseMirrorNode}
73
+ // Iterates over parent nodes starting from the given `$pos`, returning closest node of a given `nodeType`. `start` points to the start position of the node, `pos` points directly before the node.
74
+ //
75
+ // ```javascript
76
+ // const parent = findParentNodeOfTypeClosestToPos(state.doc.resolve(10), schema.nodes.paragraph);
77
+ // ```
78
+ export const findParentNodeOfTypeClosestToPos = ($pos, nodeType) => {
79
+ return findParentNodeClosestToPos($pos, node =>
80
+ equalNodeType(nodeType, node)
81
+ );
82
+ };
83
+
84
+ // :: (nodeType: union<NodeType, [NodeType]>) → (selection: Selection) → boolean
85
+ // Checks if there's a parent node of a given `nodeType`.
86
+ //
87
+ // ```javascript
88
+ // if (hasParentNodeOfType(schema.nodes.table)(selection)) {
89
+ // // ....
90
+ // }
91
+ // ```
92
+ export const hasParentNodeOfType = nodeType => selection => {
93
+ return hasParentNode(node => equalNodeType(nodeType, node))(selection);
94
+ };
95
+
96
+ // :: (nodeType: union<NodeType, [NodeType]>, domAtPos: (pos: number) → {node: dom.Node, offset: number}) → (selection: Selection) → ?dom.Node
97
+ // Iterates over parent nodes, returning DOM reference of the closest node of a given `nodeType`.
98
+ //
99
+ // ```javascript
100
+ // const domAtPos = view.domAtPos.bind(view);
101
+ // const parent = findParentDomRefOfType(schema.nodes.codeBlock, domAtPos)(selection); // <pre>
102
+ // ```
103
+ export const findParentDomRefOfType = (nodeType, domAtPos) => selection => {
104
+ return findParentDomRef(node => equalNodeType(nodeType, node), domAtPos)(
105
+ selection
106
+ );
107
+ };
108
+
109
+ // :: (nodeType: union<NodeType, [NodeType]>) → (selection: Selection) → ?{pos: number, start: number, depth: number, node: ProseMirrorNode}
110
+ // Returns a node of a given `nodeType` if it is selected. `start` points to the start position of the node, `pos` points directly before the node.
111
+ //
112
+ // ```javascript
113
+ // const { extension, inlineExtension, bodiedExtension } = schema.nodes;
114
+ // const selectedNode = findSelectedNodeOfType([
115
+ // extension,
116
+ // inlineExtension,
117
+ // bodiedExtension,
118
+ // ])(selection);
119
+ // ```
120
+ export const findSelectedNodeOfType = nodeType => selection => {
121
+ if (isNodeSelection(selection)) {
122
+ const { node, $from } = selection;
123
+ if (equalNodeType(nodeType, node)) {
124
+ return { node, pos: $from.pos, depth: $from.depth };
125
+ }
126
+ }
127
+ };
128
+
129
+ // :: (selection: Selection) → ?number
130
+ // Returns position of the previous node.
131
+ //
132
+ // ```javascript
133
+ // const pos = findPositionOfNodeBefore(tr.selection);
134
+ // ```
135
+ export const findPositionOfNodeBefore = selection => {
136
+ const { nodeBefore } = selection.$from;
137
+ const maybeSelection = Selection.findFrom(selection.$from, -1);
138
+ if (maybeSelection && nodeBefore) {
139
+ // leaf node
140
+ const parent = findParentNodeOfType(nodeBefore.type)(maybeSelection);
141
+ if (parent) {
142
+ return parent.pos;
143
+ }
144
+ return maybeSelection.$from.pos;
145
+ }
146
+ };
147
+
148
+ // :: (position: number, domAtPos: (pos: number) → {node: dom.Node, offset: number}) → dom.Node
149
+ // Returns DOM reference of a node at a given `position`. If the node type is of type `TEXT_NODE` it will return the reference of the parent node.
150
+ //
151
+ // ```javascript
152
+ // const domAtPos = view.domAtPos.bind(view);
153
+ // const ref = findDomRefAtPos($from.pos, domAtPos);
154
+ // ```
155
+ export const findDomRefAtPos = (position, domAtPos) => {
156
+ const dom = domAtPos(position);
157
+ const node = dom.node.childNodes[dom.offset];
158
+
159
+ if (dom.node.nodeType === Node.TEXT_NODE) {
160
+ return dom.node.parentNode;
161
+ }
162
+
163
+ if (!node || node.nodeType === Node.TEXT_NODE) {
164
+ return dom.node;
165
+ }
166
+
167
+ return node;
168
+ };
@@ -0,0 +1,257 @@
1
+ import { NodeSelection, Selection } from 'prosemirror-state';
2
+ import { Fragment } from 'prosemirror-model';
3
+ import { findParentNodeOfType, findPositionOfNodeBefore } from './selection';
4
+ import {
5
+ cloneTr,
6
+ isNodeSelection,
7
+ replaceNodeAtPos,
8
+ removeNodeAtPos,
9
+ canInsert,
10
+ isEmptyParagraph
11
+ } from './helpers';
12
+
13
+ // :: (nodeType: union<NodeType, [NodeType]>) → (tr: Transaction) → Transaction
14
+ // Returns a new transaction that removes a node of a given `nodeType`. It will return an original transaction if parent node hasn't been found.
15
+ //
16
+ // ```javascript
17
+ // dispatch(
18
+ // removeParentNodeOfType(schema.nodes.table)(tr)
19
+ // );
20
+ // ```
21
+ export const removeParentNodeOfType = nodeType => tr => {
22
+ const parent = findParentNodeOfType(nodeType)(tr.selection);
23
+ if (parent) {
24
+ return removeNodeAtPos(parent.pos)(tr);
25
+ }
26
+ return tr;
27
+ };
28
+
29
+ // :: (nodeType: union<NodeType, [NodeType]>, content: union<ProseMirrorNode, Fragment>) → (tr: Transaction) → Transaction
30
+ // Returns a new transaction that replaces parent node of a given `nodeType` with the given `content`. It will return an original transaction if either parent node hasn't been found or replacing is not possible.
31
+ //
32
+ // ```javascript
33
+ // const node = schema.nodes.paragraph.createChecked({}, schema.text('new'));
34
+ //
35
+ // dispatch(
36
+ // replaceParentNodeOfType(schema.nodes.table, node)(tr)
37
+ // );
38
+ // ```
39
+ export const replaceParentNodeOfType = (nodeType, content) => tr => {
40
+ if (!Array.isArray(nodeType)) {
41
+ nodeType = [nodeType];
42
+ }
43
+ for (let i = 0, count = nodeType.length; i < count; i++) {
44
+ const parent = findParentNodeOfType(nodeType[i])(tr.selection);
45
+ if (parent) {
46
+ const newTr = replaceNodeAtPos(parent.pos, content)(tr);
47
+ if (newTr !== tr) {
48
+ return newTr;
49
+ }
50
+ }
51
+ }
52
+ return tr;
53
+ };
54
+
55
+ // :: (tr: Transaction) → Transaction
56
+ // Returns a new transaction that removes selected node. It will return an original transaction if current selection is not a `NodeSelection`.
57
+ //
58
+ // ```javascript
59
+ // dispatch(
60
+ // removeSelectedNode(tr)
61
+ // );
62
+ // ```
63
+ export const removeSelectedNode = tr => {
64
+ if (isNodeSelection(tr.selection)) {
65
+ const from = tr.selection.$from.pos;
66
+ const to = tr.selection.$to.pos;
67
+ return cloneTr(tr.delete(from, to));
68
+ }
69
+ return tr;
70
+ };
71
+
72
+ // :: (content: union<ProseMirrorNode, ProseMirrorFragment>) → (tr: Transaction) → Transaction
73
+ // Returns a new transaction that replaces selected node with a given `node`, keeping NodeSelection on the new `node`.
74
+ // It will return the original transaction if either current selection is not a NodeSelection or replacing is not possible.
75
+ //
76
+ // ```javascript
77
+ // const node = schema.nodes.paragraph.createChecked({}, schema.text('new'));
78
+ // dispatch(
79
+ // replaceSelectedNode(node)(tr)
80
+ // );
81
+ // ```
82
+ export const replaceSelectedNode = content => tr => {
83
+ if (isNodeSelection(tr.selection)) {
84
+ const { $from, $to } = tr.selection;
85
+ if (
86
+ (content instanceof Fragment &&
87
+ $from.parent.canReplace($from.index(), $from.indexAfter(), content)) ||
88
+ $from.parent.canReplaceWith(
89
+ $from.index(),
90
+ $from.indexAfter(),
91
+ content.type
92
+ )
93
+ ) {
94
+ return cloneTr(
95
+ tr
96
+ .replaceWith($from.pos, $to.pos, content)
97
+ // restore node selection
98
+ .setSelection(new NodeSelection(tr.doc.resolve($from.pos)))
99
+ );
100
+ }
101
+ }
102
+ return tr;
103
+ };
104
+
105
+ // :: (position: number, dir: ?number) → (tr: Transaction) → Transaction
106
+ // Returns a new transaction that tries to find a valid cursor selection starting at the given `position`
107
+ // and searching back if `dir` is negative, and forward if positive.
108
+ // If a valid cursor position hasn't been found, it will return the original transaction.
109
+ //
110
+ // ```javascript
111
+ // dispatch(
112
+ // setTextSelection(5)(tr)
113
+ // );
114
+ // ```
115
+ export const setTextSelection = (position, dir = 1) => tr => {
116
+ const nextSelection = Selection.findFrom(tr.doc.resolve(position), dir, true);
117
+ if (nextSelection) {
118
+ return tr.setSelection(nextSelection);
119
+ }
120
+ return tr;
121
+ };
122
+
123
+ const isSelectableNode = node => node.type && node.type.spec.selectable;
124
+ const shouldSelectNode = node => isSelectableNode(node) && node.type.isLeaf;
125
+
126
+ const setSelection = (node, pos, tr) => {
127
+ if (shouldSelectNode(node)) {
128
+ return tr.setSelection(new NodeSelection(tr.doc.resolve(pos)));
129
+ }
130
+ return setTextSelection(pos)(tr);
131
+ };
132
+
133
+ // :: (content: union<ProseMirrorNode, Fragment>, position: ?number, tryToReplace?: boolean) → (tr: Transaction) → Transaction
134
+ // Returns a new transaction that inserts a given `content` at the current cursor position, or at a given `position`, if it is allowed by schema. If schema restricts such nesting, it will try to find an appropriate place for a given node in the document, looping through parent nodes up until the root document node.
135
+ // If `tryToReplace` is true and current selection is a NodeSelection, it will replace selected node with inserted content if its allowed by schema.
136
+ // If cursor is inside of an empty paragraph, it will try to replace that paragraph with the given content. If insertion is successful and inserted node has content, it will set cursor inside of that content.
137
+ // It will return an original transaction if the place for insertion hasn't been found.
138
+ //
139
+ // ```javascript
140
+ // const node = schema.nodes.extension.createChecked({});
141
+ // dispatch(
142
+ // safeInsert(node)(tr)
143
+ // );
144
+ // ```
145
+ export const safeInsert = (content, position, tryToReplace) => tr => {
146
+ const hasPosition = typeof position === 'number';
147
+ const { $from } = tr.selection;
148
+ const $insertPos = hasPosition
149
+ ? tr.doc.resolve(position)
150
+ : isNodeSelection(tr.selection)
151
+ ? tr.doc.resolve($from.pos + 1)
152
+ : $from;
153
+ const { parent } = $insertPos;
154
+
155
+ // try to replace selected node
156
+ if (isNodeSelection(tr.selection) && tryToReplace) {
157
+ const oldTr = tr;
158
+ tr = replaceSelectedNode(content)(tr);
159
+ if (oldTr !== tr) {
160
+ return tr;
161
+ }
162
+ }
163
+
164
+ // try to replace an empty paragraph
165
+ if (isEmptyParagraph(parent)) {
166
+ const oldTr = tr;
167
+ tr = replaceParentNodeOfType(parent.type, content)(tr);
168
+ if (oldTr !== tr) {
169
+ const pos = isSelectableNode(content)
170
+ ? // for selectable node, selection position would be the position of the replaced parent
171
+ $insertPos.before($insertPos.depth)
172
+ : $insertPos.pos;
173
+ return setSelection(content, pos, tr);
174
+ }
175
+ }
176
+
177
+ // given node is allowed at the current cursor position
178
+ if (canInsert($insertPos, content)) {
179
+ tr.insert($insertPos.pos, content);
180
+ const pos = hasPosition
181
+ ? $insertPos.pos
182
+ : isSelectableNode(content)
183
+ ? // for atom nodes selection position after insertion is the previous pos
184
+ tr.selection.$anchor.pos - 1
185
+ : tr.selection.$anchor.pos;
186
+ return cloneTr(setSelection(content, pos, tr));
187
+ }
188
+
189
+ // looking for a place in the doc where the node is allowed
190
+ for (let i = $insertPos.depth; i > 0; i--) {
191
+ const pos = $insertPos.after(i);
192
+ const $pos = tr.doc.resolve(pos);
193
+ if (canInsert($pos, content)) {
194
+ tr.insert(pos, content);
195
+ return cloneTr(setSelection(content, pos, tr));
196
+ }
197
+ }
198
+ return tr;
199
+ };
200
+
201
+ // :: (nodeType: union<NodeType, [NodeType]>, type: ?union<NodeType, null>, attrs: ?union<Object, null>, marks?: [Mark]) → (tr: Transaction) → Transaction
202
+ // Returns a transaction that changes the type, attributes, and/or marks of the parent node of a given `nodeType`.
203
+ //
204
+ // ```javascript
205
+ // const node = schema.nodes.extension.createChecked({});
206
+ // dispatch(
207
+ // setParentNodeMarkup(schema.nodes.panel, null, { panelType })(tr);
208
+ // );
209
+ // ```
210
+ export const setParentNodeMarkup = (nodeType, type, attrs, marks) => tr => {
211
+ const parent = findParentNodeOfType(nodeType)(tr.selection);
212
+ if (parent) {
213
+ return cloneTr(
214
+ tr.setNodeMarkup(
215
+ parent.pos,
216
+ type,
217
+ Object.assign({}, parent.node.attrs, attrs),
218
+ marks
219
+ )
220
+ );
221
+ }
222
+ return tr;
223
+ };
224
+
225
+ // :: (nodeType: union<NodeType, [NodeType]>) → (tr: Transaction) → Transaction
226
+ // Returns a new transaction that sets a `NodeSelection` on a parent node of a `given nodeType`.
227
+ //
228
+ // ```javascript
229
+ // dispatch(
230
+ // selectParentNodeOfType([tableCell, tableHeader])(state.tr)
231
+ // );
232
+ // ```
233
+ export const selectParentNodeOfType = nodeType => tr => {
234
+ if (!isNodeSelection(tr.selection)) {
235
+ const parent = findParentNodeOfType(nodeType)(tr.selection);
236
+ if (parent) {
237
+ return cloneTr(tr.setSelection(NodeSelection.create(tr.doc, parent.pos)));
238
+ }
239
+ }
240
+ return tr;
241
+ };
242
+
243
+ // :: (tr: Transaction) → Transaction
244
+ // Returns a new transaction that deletes previous node.
245
+ //
246
+ // ```javascript
247
+ // dispatch(
248
+ // removeNodeBefore(state.tr)
249
+ // );
250
+ // ```
251
+ export const removeNodeBefore = tr => {
252
+ const position = findPositionOfNodeBefore(tr.selection);
253
+ if (typeof position === 'number') {
254
+ return removeNodeAtPos(position)(tr);
255
+ }
256
+ return tr;
257
+ };
@@ -0,0 +1,81 @@
1
+ {
2
+ "name": "prosemirror-utils",
3
+ "version": "1.0.0-0",
4
+ "description": "Utils library for ProseMirror",
5
+ "main": "dist/index.js",
6
+ "author": {
7
+ "name": "Eduard Shvedai",
8
+ "email": "eshvedai@gmail.com",
9
+ "url": "https://github.com/eshvedai"
10
+ },
11
+ "maintainers": [
12
+ {
13
+ "name": "Eduard Shvedai",
14
+ "email": "eshvedai@atlassian.com"
15
+ }
16
+ ],
17
+ "license": "Apache-2.0",
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "git://github.com/atlassian/prosemirror-utils.git"
21
+ },
22
+ "keywords": [
23
+ "ProseMirror",
24
+ "utils",
25
+ "helpers"
26
+ ],
27
+ "jest": {
28
+ "transform": {
29
+ "^.+\\.js$": "babel-jest"
30
+ },
31
+ "setupTestFrameworkScriptFile": "./jestFrameworkSetup.js",
32
+ "testURL": "http://localhost/"
33
+ },
34
+ "typings": "typings.d.ts",
35
+ "files": [
36
+ "dist",
37
+ "typings.d.ts"
38
+ ],
39
+ "scripts": {
40
+ "build": "rollup -c",
41
+ "build_readme": "builddocs --name utils --format markdown --main src/README.md src/*.js > README.md",
42
+ "build_all": "npm run build && npm run build_readme",
43
+ "test": "NODE_ENV=testing jest",
44
+ "test-ci": "NODE_ENV=testing jest --coverage && codecov",
45
+ "prepare": "npm run build",
46
+ "precommit": "lint-staged"
47
+ },
48
+ "peerDependencies": {
49
+ "prosemirror-model": "^1.0.0",
50
+ "prosemirror-state": "^1.0.1"
51
+ },
52
+ "devDependencies": {
53
+ "babel-core": "^6.26.3",
54
+ "babel-jest": "^23.6.0",
55
+ "babel-preset-env": "^1.7.0",
56
+ "builddocs": "^0.3.2",
57
+ "codecov": "^3.1.0",
58
+ "husky": "^1.3.0",
59
+ "jest": "^23.6.0",
60
+ "jest-diff": "^23.6.0",
61
+ "lint-staged": "^8.1.0",
62
+ "prettier": "^1.15.3",
63
+ "prosemirror-model": "^1.0.0",
64
+ "prosemirror-schema-basic": "^1.0.0",
65
+ "prosemirror-state": "^1.0.1",
66
+ "prosemirror-test-builder": "^1.0.1",
67
+ "prosemirror-view": "^1.1.1",
68
+ "rollup": "^0.56.3",
69
+ "rollup-plugin-babel": "^3.0.3"
70
+ },
71
+ "lint-staged": {
72
+ "*.{js, md}": [
73
+ "prettier --write",
74
+ "git add"
75
+ ]
76
+ },
77
+ "prettier": {
78
+ "singleQuote": true,
79
+ "trailing-comma": "es5"
80
+ }
81
+ }
@@ -0,0 +1,79 @@
1
+ import { Node as ProsemirrorNode, Schema, NodeType, Mark, MarkType, ResolvedPos, Fragment } from 'prosemirror-model';
2
+ import { Selection, Transaction } from 'prosemirror-state';
3
+
4
+ export type Predicate = (node: ProsemirrorNode) => boolean;
5
+
6
+ export type DomAtPos = (pos: number) => {node: Node, offset: number};
7
+
8
+ export type ContentNodeWithPos = {pos: number, start: number, depth: number, node: ProsemirrorNode};
9
+
10
+ export type NodeWithPos = {pos: number, node: ProsemirrorNode};
11
+
12
+ export type CellTransform = (cell: ContentNodeWithPos, tr: Transaction) => Transaction;
13
+
14
+ export type MovementOptions = { tryToFit: boolean, direction?: -1 | 0 | 1 };
15
+
16
+ // Selection
17
+ export function findParentNode(predicate: Predicate): (selection: Selection) => ContentNodeWithPos | undefined;
18
+
19
+ export function findParentNodeClosestToPos($pos: ResolvedPos, predicate: Predicate): ContentNodeWithPos | undefined;
20
+
21
+ export function findParentDomRef(predicate: Predicate, domAtPos: DomAtPos): (selection: Selection) => Node | undefined;
22
+
23
+ export function hasParentNode(predicate: Predicate): (selection: Selection) => boolean;
24
+
25
+ export function findParentNodeOfType(nodeType: NodeType | NodeType[]): (selection: Selection) => ContentNodeWithPos | undefined;
26
+
27
+ export function findParentNodeOfTypeClosestToPos($pos: ResolvedPos, nodeType: NodeType | NodeType[]): ContentNodeWithPos | undefined;
28
+
29
+ export function hasParentNodeOfType(nodeType: NodeType | NodeType[]): (selection: Selection) => boolean;
30
+
31
+ export function findParentDomRefOfType(nodeType: NodeType | NodeType[], domAtPos: DomAtPos): (selection: Selection) => Node | undefined;
32
+
33
+ export function findSelectedNodeOfType(nodeType: NodeType | NodeType[]): (selection: Selection) => ContentNodeWithPos | undefined;
34
+
35
+ export function isNodeSelection(selection: Selection): boolean;
36
+
37
+ export function findPositionOfNodeBefore(selection: Selection): number | undefined;
38
+
39
+ export function findDomRefAtPos(position: number, domAtPos: DomAtPos): Node;
40
+
41
+ // Node
42
+ export function flatten(node: ProsemirrorNode, descend?: boolean): NodeWithPos[];
43
+
44
+ export function findChildren(node: ProsemirrorNode, predicate: Predicate, descend?: boolean): NodeWithPos[];
45
+
46
+ export function findTextNodes(node: ProsemirrorNode, descend?: boolean): NodeWithPos[];
47
+
48
+ export function findInlineNodes(node: ProsemirrorNode, descend?: boolean): NodeWithPos[];
49
+
50
+ export function findBlockNodes(node: ProsemirrorNode, descend?: boolean): NodeWithPos[];
51
+
52
+ export function findChildrenByAttr(node: ProsemirrorNode, predicate: Predicate, descend?: boolean): NodeWithPos[];
53
+
54
+ export function findChildrenByType(node: ProsemirrorNode, nodeType: NodeType, descend?: boolean): NodeWithPos[];
55
+
56
+ export function findChildrenByMark(node: ProsemirrorNode, markType: MarkType, descend?: boolean): NodeWithPos[];
57
+
58
+ export function contains(node: ProsemirrorNode, nodeType: NodeType): boolean;
59
+
60
+ // Transforms
61
+ export function removeParentNodeOfType(nodeType: NodeType | NodeType[]): (tr: Transaction) => Transaction;
62
+
63
+ export function replaceParentNodeOfType(nodeType: NodeType | NodeType[], node: ProsemirrorNode): (tr: Transaction) => Transaction;
64
+
65
+ export function removeSelectedNode(tr: Transaction): Transaction;
66
+
67
+ export function replaceSelectedNode(node: ProsemirrorNode): (tr: Transaction) => Transaction;
68
+
69
+ export function canInsert($pos: ResolvedPos, node: ProsemirrorNode | Fragment): boolean;
70
+
71
+ export function safeInsert(node: ProsemirrorNode | Fragment, position?: number, tryToReplace?: boolean): (tr: Transaction) => Transaction;
72
+
73
+ export function setParentNodeMarkup(nodeType: NodeType | NodeType[], type?: NodeType | null, attrs?: { [key: string]: any } | null, marks?: Mark[]): (tr: Transaction) => Transaction;
74
+
75
+ export function selectParentNodeOfType(nodeType: NodeType | NodeType[]): (tr: Transaction) => Transaction;
76
+
77
+ export function removeNodeBefore(tr: Transaction): Transaction;
78
+
79
+ export function setTextSelection(position: number, dir?: number): (tr: Transaction) => Transaction;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@modusoperandi/licit",
3
- "version": "0.1.9",
3
+ "version": "0.13.2",
4
4
  "subversion": "1",
5
5
  "description": "Rich text editor built with React and ProseMirror",
6
6
  "main": "dist/index.js",
@@ -9,6 +9,9 @@
9
9
  "type": "git",
10
10
  "url": "git+https://github.com/MO-Movia/licit.git"
11
11
  },
12
+ "bundleDependencies": [
13
+ "prosemirror-utils"
14
+ ],
12
15
  "scripts": {
13
16
  "test": "jest",
14
17
  "build:bom": "cyclonedx-bom -o dist/bom.xml",
@@ -75,20 +78,23 @@
75
78
  "husky": "^4.3.0",
76
79
  "identity-obj-proxy": "^3.0.0",
77
80
  "jest": "^26.6.3",
81
+ "jest-prosemirror": "^1.0.19",
82
+ "jest-sonar-reporter": "^2.0.0",
78
83
  "lint-staged": "^10.4.0",
79
84
  "mkdirp": "^1.0.4",
80
85
  "prettier": "^2.1.2",
81
- "react-test-renderer": "^17.0.1",
82
86
  "stylelint": "^13.7.2",
83
87
  "stylelint-config-standard": "^20.0.0",
84
88
  "stylelint-prettier": "^1.2.0",
85
89
  "terser-webpack-plugin": "^3.1.0",
86
90
  "webpack": "^4.44.2",
91
+ "webpack-cli": "^4.9.1",
87
92
  "webpack-dev-server": "^3.11.0",
88
93
  "write-file-webpack-plugin": "4.5.1"
89
94
  },
90
95
  "dependencies": {
91
- "@modusoperandi/licit-doc-attrs-step": "^0.1.1",
96
+ "@modusoperandi/licit-doc-attrs-step": "^0.1.2",
97
+ "@modusoperandi/licit-ui-commands": "^0.1.4",
92
98
  "body-parser": "^1.19.0",
93
99
  "browserkeymap": "2.0.2",
94
100
  "classnames": "2.2.6",
@@ -107,16 +113,16 @@
107
113
  "prosemirror-collab": "1.2.2",
108
114
  "prosemirror-commands": "1.1.5",
109
115
  "prosemirror-dev-tools": "3.0.2",
110
- "prosemirror-dropcursor": "1.3.2",
111
- "prosemirror-gapcursor": "1.1.5",
116
+ "prosemirror-dropcursor": "^1.3.5",
117
+ "prosemirror-gapcursor": "^1.2.2",
112
118
  "prosemirror-history": "1.1.3",
113
119
  "prosemirror-inputrules": "1.1.3",
114
120
  "prosemirror-keymap": "^1.1.4",
115
- "prosemirror-model": "^1.13.1",
121
+ "prosemirror-model": "^1.16.1",
116
122
  "prosemirror-state": "^1.3.4",
117
123
  "prosemirror-tables": "^1.1.1",
118
124
  "prosemirror-transform": "^1.2.9",
119
- "prosemirror-utils": "0.9.6",
125
+ "prosemirror-utils": "file:prosemirror-utils-1.0.0-0.tgz",
120
126
  "prosemirror-view": "^1.17.3",
121
127
  "query-string": "6.13.1",
122
128
  "react": "^16.13.1",
@@ -153,7 +159,7 @@
153
159
  "jest": {
154
160
  "rootDir": "src",
155
161
  "transform": {
156
- "^.+\\.jsx?$": "babel-jest"
162
+ "^.+\\.js?$": "babel-jest"
157
163
  },
158
164
  "moduleNameMapper": {
159
165
  "\\.(css|less|scss|sass)$": "identity-obj-proxy"
File without changes
File without changes
@@ -6,7 +6,7 @@ import { findParentNodeOfType } from 'prosemirror-utils';
6
6
  import { EditorView } from 'prosemirror-view';
7
7
 
8
8
  import { CODE_BLOCK } from './NodeNames';
9
- import noop from './noop';
9
+ import { noop } from '@modusoperandi/licit-ui-commands';
10
10
  import toggleCodeBlock from './toggleCodeBlock';
11
11
  import { UICommand } from '@modusoperandi/licit-doc-attrs-step';
12
12
 
@@ -8,7 +8,7 @@ import { EditorView } from 'prosemirror-view';
8
8
  import { SetDocAttrStep } from '@modusoperandi/licit-doc-attrs-step';
9
9
  import DocLayoutEditor from './ui/DocLayoutEditor';
10
10
  import { UICommand } from '@modusoperandi/licit-doc-attrs-step';
11
- import createPopUp from './ui/createPopUp';
11
+ import { createPopUp } from '@modusoperandi/licit-ui-commands';
12
12
 
13
13
  import type { DocLayoutEditorValue } from './ui/DocLayoutEditor';
14
14