@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
@@ -1,177 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.setTextLineSpacing = setTextLineSpacing;
7
- exports.default = void 0;
8
-
9
- var _licitDocAttrsStep = require("@modusoperandi/licit-doc-attrs-step");
10
-
11
- var _prosemirrorState = require("prosemirror-state");
12
-
13
- var _NodeNames = require("./NodeNames");
14
-
15
- var _prosemirrorView = require("prosemirror-view");
16
-
17
- var _prosemirrorModel = require("prosemirror-model");
18
-
19
- var _prosemirrorTransform = require("prosemirror-transform");
20
-
21
- var _toCSSLineSpacing = require("./ui/toCSSLineSpacing");
22
-
23
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
24
-
25
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
26
-
27
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
28
-
29
- function setTextLineSpacing(tr, schema, lineSpacing) {
30
- const {
31
- selection,
32
- doc
33
- } = tr;
34
-
35
- if (!selection || !doc) {
36
- return tr;
37
- }
38
-
39
- if (!(selection instanceof _prosemirrorState.TextSelection) && !(selection instanceof _prosemirrorState.AllSelection)) {
40
- return tr;
41
- }
42
-
43
- const {
44
- from,
45
- to
46
- } = selection;
47
- const paragraph = schema.nodes[_NodeNames.PARAGRAPH];
48
- const heading = schema.nodes[_NodeNames.HEADING];
49
- const listItem = schema.nodes[_NodeNames.LIST_ITEM];
50
- const blockquote = schema.nodes[_NodeNames.BLOCKQUOTE];
51
-
52
- if (!paragraph && !heading && !listItem && !blockquote) {
53
- return tr;
54
- }
55
-
56
- const tasks = [];
57
- const lineSpacingValue = lineSpacing || null;
58
- doc.nodesBetween(from, to, (node, pos, parentNode) => {
59
- const nodeType = node.type;
60
-
61
- if (nodeType === paragraph || nodeType === heading || nodeType === listItem || nodeType === blockquote) {
62
- const lineSpacing = node.attrs.lineSpacing || null;
63
-
64
- if (lineSpacing !== lineSpacingValue) {
65
- tasks.push({
66
- node,
67
- pos,
68
- nodeType
69
- });
70
- }
71
-
72
- return nodeType === listItem ? true : false;
73
- }
74
-
75
- return true;
76
- });
77
-
78
- if (!tasks.length) {
79
- return tr;
80
- }
81
-
82
- tasks.forEach(job => {
83
- const {
84
- node,
85
- pos,
86
- nodeType
87
- } = job;
88
- let {
89
- attrs
90
- } = node;
91
-
92
- if (lineSpacingValue) {
93
- attrs = _objectSpread(_objectSpread({}, attrs), {}, {
94
- lineSpacing: lineSpacingValue
95
- });
96
- } else {
97
- attrs = _objectSpread(_objectSpread({}, attrs), {}, {
98
- lineSpacing: null
99
- });
100
- }
101
-
102
- tr = tr.setNodeMarkup(pos, nodeType, attrs, node.marks);
103
- });
104
- return tr;
105
- }
106
-
107
- function createGroup() {
108
- const group = {
109
- Single: new TextLineSpacingCommand(_toCSSLineSpacing.SINGLE_LINE_SPACING),
110
- '1.15': new TextLineSpacingCommand(_toCSSLineSpacing.LINE_SPACING_115),
111
- '1.5': new TextLineSpacingCommand(_toCSSLineSpacing.LINE_SPACING_150),
112
- Double: new TextLineSpacingCommand(_toCSSLineSpacing.DOUBLE_LINE_SPACING)
113
- };
114
- return [group];
115
- }
116
-
117
- class TextLineSpacingCommand extends _licitDocAttrsStep.UICommand {
118
- constructor(lineSpacing) {
119
- super();
120
-
121
- _defineProperty(this, "_lineSpacing", void 0);
122
-
123
- _defineProperty(this, "isActive", state => {
124
- const {
125
- selection,
126
- doc,
127
- schema
128
- } = state;
129
- const {
130
- from,
131
- to
132
- } = selection;
133
- const paragraph = schema.nodes[_NodeNames.PARAGRAPH];
134
- const heading = schema.nodes[_NodeNames.HEADING];
135
- let keepLooking = true;
136
- let active = false;
137
- doc.nodesBetween(from, to, (node, pos) => {
138
- const nodeType = node.type;
139
-
140
- if (keepLooking && (nodeType === paragraph || nodeType === heading) && node.attrs.lineSpacing === this._lineSpacing) {
141
- keepLooking = false;
142
- active = true;
143
- }
144
-
145
- return keepLooking;
146
- });
147
- return active;
148
- });
149
-
150
- _defineProperty(this, "isEnabled", state => {
151
- return this.isActive(state) || this.execute(state);
152
- });
153
-
154
- _defineProperty(this, "execute", (state, dispatch, view) => {
155
- const {
156
- schema,
157
- selection
158
- } = state;
159
- const tr = setTextLineSpacing(state.tr.setSelection(selection), schema, this._lineSpacing);
160
-
161
- if (tr.docChanged) {
162
- dispatch && dispatch(tr);
163
- return true;
164
- } else {
165
- return false;
166
- }
167
- });
168
-
169
- this._lineSpacing = lineSpacing;
170
- }
171
-
172
- }
173
-
174
- _defineProperty(TextLineSpacingCommand, "createGroup", createGroup);
175
-
176
- var _default = TextLineSpacingCommand;
177
- exports.default = _default;
@@ -1,157 +0,0 @@
1
- // @flow
2
-
3
- import { UICommand } from '@modusoperandi/licit-doc-attrs-step';
4
- import { AllSelection, TextSelection } from 'prosemirror-state';
5
- import { BLOCKQUOTE, HEADING, LIST_ITEM, PARAGRAPH } from './NodeNames';
6
- import { EditorState } from 'prosemirror-state';
7
- import { EditorView } from 'prosemirror-view';
8
- import { Schema } from 'prosemirror-model';
9
- import { Transform } from 'prosemirror-transform';
10
- import {
11
- DOUBLE_LINE_SPACING,
12
- SINGLE_LINE_SPACING,
13
- LINE_SPACING_115,
14
- LINE_SPACING_150,
15
- } from './ui/toCSSLineSpacing';
16
-
17
- export function setTextLineSpacing(
18
- tr: Transform,
19
- schema: Schema,
20
- lineSpacing: ?string
21
- ): Transform {
22
- const { selection, doc } = tr;
23
- if (!selection || !doc) {
24
- return tr;
25
- }
26
-
27
- if (
28
- !(selection instanceof TextSelection) &&
29
- !(selection instanceof AllSelection)
30
- ) {
31
- return tr;
32
- }
33
-
34
- const { from, to } = selection;
35
- const paragraph = schema.nodes[PARAGRAPH];
36
- const heading = schema.nodes[HEADING];
37
- const listItem = schema.nodes[LIST_ITEM];
38
- const blockquote = schema.nodes[BLOCKQUOTE];
39
- if (!paragraph && !heading && !listItem && !blockquote) {
40
- return tr;
41
- }
42
-
43
- const tasks = [];
44
- const lineSpacingValue = lineSpacing || null;
45
-
46
- doc.nodesBetween(from, to, (node, pos, parentNode) => {
47
- const nodeType = node.type;
48
- if (
49
- nodeType === paragraph ||
50
- nodeType === heading ||
51
- nodeType === listItem ||
52
- nodeType === blockquote
53
- ) {
54
- const lineSpacing = node.attrs.lineSpacing || null;
55
- if (lineSpacing !== lineSpacingValue) {
56
- tasks.push({
57
- node,
58
- pos,
59
- nodeType,
60
- });
61
- }
62
- return nodeType === listItem ? true : false;
63
- }
64
- return true;
65
- });
66
-
67
- if (!tasks.length) {
68
- return tr;
69
- }
70
-
71
- tasks.forEach((job) => {
72
- const { node, pos, nodeType } = job;
73
- let { attrs } = node;
74
- if (lineSpacingValue) {
75
- attrs = {
76
- ...attrs,
77
- lineSpacing: lineSpacingValue,
78
- };
79
- } else {
80
- attrs = {
81
- ...attrs,
82
- lineSpacing: null,
83
- };
84
- }
85
- tr = tr.setNodeMarkup(pos, nodeType, attrs, node.marks);
86
- });
87
-
88
- return tr;
89
- }
90
-
91
- function createGroup(): Array<{ [string]: TextLineSpacingCommand }> {
92
- const group = {
93
- Single: new TextLineSpacingCommand(SINGLE_LINE_SPACING),
94
- '1.15': new TextLineSpacingCommand(LINE_SPACING_115),
95
- '1.5': new TextLineSpacingCommand(LINE_SPACING_150),
96
- Double: new TextLineSpacingCommand(DOUBLE_LINE_SPACING),
97
- };
98
- return [group];
99
- }
100
-
101
- class TextLineSpacingCommand extends UICommand {
102
- _lineSpacing: ?string;
103
-
104
- static createGroup = createGroup;
105
-
106
- constructor(lineSpacing: ?string) {
107
- super();
108
- this._lineSpacing = lineSpacing;
109
- }
110
-
111
- isActive = (state: EditorState): boolean => {
112
- const { selection, doc, schema } = state;
113
- const { from, to } = selection;
114
- const paragraph = schema.nodes[PARAGRAPH];
115
- const heading = schema.nodes[HEADING];
116
- let keepLooking = true;
117
- let active = false;
118
- doc.nodesBetween(from, to, (node, pos) => {
119
- const nodeType = node.type;
120
- if (
121
- keepLooking &&
122
- (nodeType === paragraph || nodeType === heading) &&
123
- node.attrs.lineSpacing === this._lineSpacing
124
- ) {
125
- keepLooking = false;
126
- active = true;
127
- }
128
- return keepLooking;
129
- });
130
- return active;
131
- };
132
-
133
- isEnabled = (state: EditorState): boolean => {
134
- return this.isActive(state) || this.execute(state);
135
- };
136
-
137
- execute = (
138
- state: EditorState,
139
- dispatch: ?(tr: Transform) => void,
140
- view: ?EditorView
141
- ): boolean => {
142
- const { schema, selection } = state;
143
- const tr = setTextLineSpacing(
144
- state.tr.setSelection(selection),
145
- schema,
146
- this._lineSpacing
147
- );
148
- if (tr.docChanged) {
149
- dispatch && dispatch(tr);
150
- return true;
151
- } else {
152
- return false;
153
- }
154
- };
155
- }
156
-
157
- export default TextLineSpacingCommand;
package/dist/applyMark.js DELETED
@@ -1,84 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = applyMark;
7
-
8
- var _prosemirrorModel = require("prosemirror-model");
9
-
10
- var _prosemirrorTransform = require("prosemirror-transform");
11
-
12
- function markApplies(doc, ranges, type) {
13
- for (let i = 0; i < ranges.length; i++) {
14
- const {
15
- $from,
16
- $to
17
- } = ranges[i];
18
- let can = $from.depth == 0 ? doc.type.allowsMarkType(type) : false;
19
- doc.nodesBetween($from.pos, $to.pos, node => {
20
- if (can) {
21
- return false;
22
- }
23
-
24
- can = node.inlineContent && node.type.allowsMarkType(type);
25
- return true;
26
- });
27
-
28
- if (can) {
29
- return true;
30
- }
31
- }
32
-
33
- return false;
34
- } // https://github.com/ProseMirror/prosemirror-commands/blob/master/src/commands.js
35
-
36
-
37
- function applyMark(tr, schema, markType, attrs) {
38
- if (!tr.selection || !tr.doc || !markType) {
39
- return tr;
40
- }
41
-
42
- const {
43
- empty,
44
- $cursor,
45
- ranges
46
- } = tr.selection;
47
-
48
- if (empty && !$cursor || !markApplies(tr.doc, ranges, markType)) {
49
- return tr;
50
- }
51
-
52
- if ($cursor) {
53
- tr = tr.removeStoredMark(markType); // return attrs ? tr.addStoredMark(markType.create(attrs)) : tr;
54
-
55
- return tr.addStoredMark(markType.create(attrs));
56
- }
57
-
58
- let has = false;
59
-
60
- for (let i = 0; !has && i < ranges.length; i++) {
61
- const {
62
- $from,
63
- $to
64
- } = ranges[i];
65
- has = tr.doc.rangeHasMark($from.pos, $to.pos, markType);
66
- }
67
-
68
- for (let i = 0; i < ranges.length; i++) {
69
- const {
70
- $from,
71
- $to
72
- } = ranges[i];
73
-
74
- if (has) {
75
- tr = tr.removeMark($from.pos, $to.pos, markType);
76
- }
77
-
78
- if (attrs) {
79
- tr = tr.addMark($from.pos, $to.pos, markType.create(attrs));
80
- }
81
- }
82
-
83
- return tr;
84
- }
@@ -1,61 +0,0 @@
1
- // @flow
2
-
3
- import { Mark, Schema } from 'prosemirror-model';
4
- import { Transform } from 'prosemirror-transform';
5
-
6
- function markApplies(doc, ranges, type) {
7
- for (let i = 0; i < ranges.length; i++) {
8
- const { $from, $to } = ranges[i];
9
- let can = $from.depth == 0 ? doc.type.allowsMarkType(type) : false;
10
- doc.nodesBetween($from.pos, $to.pos, (node) => {
11
- if (can) {
12
- return false;
13
- }
14
- can = node.inlineContent && node.type.allowsMarkType(type);
15
- return true;
16
- });
17
- if (can) {
18
- return true;
19
- }
20
- }
21
- return false;
22
- }
23
-
24
- // https://github.com/ProseMirror/prosemirror-commands/blob/master/src/commands.js
25
- export default function applyMark(
26
- tr: Transform,
27
- schema: Schema,
28
- markType: Mark,
29
- attrs?: ?Object
30
- ): Transform {
31
- if (!tr.selection || !tr.doc || !markType) {
32
- return tr;
33
- }
34
- const { empty, $cursor, ranges } = tr.selection;
35
- if ((empty && !$cursor) || !markApplies(tr.doc, ranges, markType)) {
36
- return tr;
37
- }
38
-
39
- if ($cursor) {
40
- tr = tr.removeStoredMark(markType);
41
- // return attrs ? tr.addStoredMark(markType.create(attrs)) : tr;
42
- return tr.addStoredMark(markType.create(attrs));
43
- }
44
-
45
- let has = false;
46
- for (let i = 0; !has && i < ranges.length; i++) {
47
- const { $from, $to } = ranges[i];
48
- has = tr.doc.rangeHasMark($from.pos, $to.pos, markType);
49
- }
50
- for (let i = 0; i < ranges.length; i++) {
51
- const { $from, $to } = ranges[i];
52
- if (has) {
53
- tr = tr.removeMark($from.pos, $to.pos, markType);
54
- }
55
- if (attrs) {
56
- tr = tr.addMark($from.pos, $to.pos, markType.create(attrs));
57
- }
58
- }
59
-
60
- return tr;
61
- }
@@ -1,160 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.clearMarks = clearMarks;
7
- exports.clearHeading = clearHeading;
8
-
9
- var _prosemirrorModel = require("prosemirror-model");
10
-
11
- var _prosemirrorTransform = require("prosemirror-transform");
12
-
13
- var _NodeNames = require("./NodeNames");
14
-
15
- var MarkNames = _interopRequireWildcard(require("./MarkNames"));
16
-
17
- var _TextAlignCommand = require("./TextAlignCommand");
18
-
19
- var _TextLineSpacingCommand = require("./TextLineSpacingCommand");
20
-
21
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
22
-
23
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
24
-
25
- const {
26
- MARK_EM,
27
- MARK_FONT_SIZE,
28
- MARK_FONT_TYPE,
29
- MARK_STRIKE,
30
- MARK_STRONG,
31
- MARK_TEXT_COLOR,
32
- MARK_TEXT_HIGHLIGHT,
33
- MARK_UNDERLINE
34
- } = MarkNames;
35
- const FORMAT_MARK_NAMES = [MARK_EM, MARK_FONT_SIZE, MARK_FONT_TYPE, MARK_STRIKE, MARK_STRONG, MARK_TEXT_COLOR, MARK_TEXT_HIGHLIGHT, MARK_UNDERLINE]; // [FS] IRAD-1053 2020-11-13
36
- // Clear format not removes the line spacing
37
-
38
- function removeTextAlignAndLineSpacing(tr, schema) {
39
- // to clear the text align format.
40
- tr = (0, _TextAlignCommand.setTextAlign)(tr, schema, null); // to clear the applied line spacing format.
41
-
42
- tr = (0, _TextLineSpacingCommand.setTextLineSpacing)(tr, schema, null);
43
- return tr;
44
- }
45
-
46
- function clearMarks(tr, schema) {
47
- const {
48
- doc,
49
- selection
50
- } = tr;
51
-
52
- if (!selection || !doc) {
53
- return tr;
54
- }
55
-
56
- const {
57
- from,
58
- to,
59
- empty
60
- } = selection;
61
-
62
- if (empty) {
63
- return tr;
64
- }
65
-
66
- const markTypesToRemove = new Set(FORMAT_MARK_NAMES.map(n => schema.marks[n]).filter(Boolean));
67
-
68
- if (!markTypesToRemove.size) {
69
- return tr;
70
- }
71
-
72
- const tasks = [];
73
- doc.nodesBetween(from, to, (node, pos) => {
74
- if (node.marks && node.marks.length) {
75
- node.marks.some(mark => {
76
- if (markTypesToRemove.has(mark.type)) {
77
- tasks.push({
78
- node,
79
- pos,
80
- mark
81
- });
82
- }
83
- });
84
- return true;
85
- }
86
-
87
- return true;
88
- });
89
-
90
- if (!tasks.length) {
91
- // It should clear text alignment and line spacing.
92
- tr = removeTextAlignAndLineSpacing(tr, schema);
93
- return tr;
94
- }
95
-
96
- tasks.forEach(job => {
97
- const {
98
- mark
99
- } = job; // [FS] IRAD-1043 2020-10-27
100
- // Issue fix on when clear the format of a selected word, the entire paragraphs style removed
101
-
102
- tr = tr.removeMark(from, to, mark.type);
103
- }); // It should clear text alignment and line spacing.
104
-
105
- tr = removeTextAlignAndLineSpacing(tr, schema);
106
- return tr;
107
- } // [FS] IRAD-948 2020-05-22
108
- // Clear Header formatting
109
-
110
-
111
- function clearHeading(tr, schema) {
112
- const {
113
- doc,
114
- selection
115
- } = tr;
116
-
117
- if (!selection || !doc) {
118
- return tr;
119
- }
120
-
121
- const {
122
- from,
123
- to,
124
- empty
125
- } = selection;
126
-
127
- if (empty) {
128
- return tr;
129
- }
130
-
131
- const {
132
- nodes
133
- } = schema;
134
- const heading = nodes[_NodeNames.HEADING];
135
- const paragraph = nodes[_NodeNames.PARAGRAPH];
136
- const tasks = [];
137
- doc.nodesBetween(from, to, (node, pos) => {
138
- if (heading === node.type) {
139
- tasks.push({
140
- node,
141
- pos
142
- });
143
- }
144
-
145
- return true;
146
- });
147
-
148
- if (!tasks.length) {
149
- return tr;
150
- }
151
-
152
- tasks.forEach(job => {
153
- const {
154
- node,
155
- pos
156
- } = job;
157
- tr = tr.setNodeMarkup(pos, paragraph, node.attrs, node.marks);
158
- });
159
- return tr;
160
- }