@atlaskit/editor-common 74.29.3 → 74.31.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (223) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/cjs/i18n/cs.js +19 -0
  3. package/dist/cjs/i18n/da.js +19 -0
  4. package/dist/cjs/i18n/de.js +19 -0
  5. package/dist/cjs/i18n/es.js +19 -0
  6. package/dist/cjs/i18n/fi.js +19 -0
  7. package/dist/cjs/i18n/fr.js +19 -0
  8. package/dist/cjs/i18n/hu.js +19 -0
  9. package/dist/cjs/i18n/it.js +19 -0
  10. package/dist/cjs/i18n/ja.js +19 -0
  11. package/dist/cjs/i18n/ko.js +19 -0
  12. package/dist/cjs/i18n/nb.js +19 -0
  13. package/dist/cjs/i18n/nl.js +19 -0
  14. package/dist/cjs/i18n/pl.js +19 -0
  15. package/dist/cjs/i18n/pt_BR.js +19 -0
  16. package/dist/cjs/i18n/ru.js +19 -0
  17. package/dist/cjs/i18n/sv.js +19 -0
  18. package/dist/cjs/i18n/th.js +19 -0
  19. package/dist/cjs/i18n/tr.js +19 -0
  20. package/dist/cjs/i18n/uk.js +19 -0
  21. package/dist/cjs/i18n/vi.js +19 -0
  22. package/dist/cjs/i18n/zh.js +19 -0
  23. package/dist/cjs/i18n/zh_TW.js +19 -0
  24. package/dist/cjs/lists/analytics.js +40 -0
  25. package/dist/cjs/lists/indentation.js +24 -0
  26. package/dist/cjs/lists/index.js +89 -0
  27. package/dist/cjs/lists/node.js +97 -0
  28. package/dist/cjs/lists/replace-content.js +24 -0
  29. package/dist/cjs/lists/selection.js +59 -0
  30. package/dist/cjs/mark/commands.js +201 -0
  31. package/dist/cjs/mark/index.js +30 -0
  32. package/dist/cjs/messages/full-page.js +25 -0
  33. package/dist/cjs/messages/index.js +7 -0
  34. package/dist/cjs/monitoring/error.js +1 -1
  35. package/dist/cjs/node-width/index.js +10 -2
  36. package/dist/cjs/ui/DropList/index.js +1 -1
  37. package/dist/cjs/ui/Toolbar/index.js +8 -0
  38. package/dist/cjs/ui/index.js +7 -0
  39. package/dist/cjs/ui-menu/DropdownMenu/index.js +16 -2
  40. package/dist/cjs/ui-menu/ToolbarArrowKeyNavigationProvider/index.js +219 -0
  41. package/dist/cjs/ui-menu/index.js +23 -4
  42. package/dist/cjs/utils/commands.js +110 -2
  43. package/dist/cjs/utils/document.js +26 -1
  44. package/dist/cjs/utils/index.js +51 -2
  45. package/dist/cjs/utils/prosemirror/autojoin.js +68 -0
  46. package/dist/cjs/version.json +1 -1
  47. package/dist/es2019/i18n/cs.js +19 -0
  48. package/dist/es2019/i18n/da.js +19 -0
  49. package/dist/es2019/i18n/de.js +19 -0
  50. package/dist/es2019/i18n/es.js +19 -0
  51. package/dist/es2019/i18n/fi.js +19 -0
  52. package/dist/es2019/i18n/fr.js +19 -0
  53. package/dist/es2019/i18n/hu.js +19 -0
  54. package/dist/es2019/i18n/it.js +19 -0
  55. package/dist/es2019/i18n/ja.js +19 -0
  56. package/dist/es2019/i18n/ko.js +19 -0
  57. package/dist/es2019/i18n/nb.js +19 -0
  58. package/dist/es2019/i18n/nl.js +19 -0
  59. package/dist/es2019/i18n/pl.js +19 -0
  60. package/dist/es2019/i18n/pt_BR.js +19 -0
  61. package/dist/es2019/i18n/ru.js +19 -0
  62. package/dist/es2019/i18n/sv.js +19 -0
  63. package/dist/es2019/i18n/th.js +19 -0
  64. package/dist/es2019/i18n/tr.js +19 -0
  65. package/dist/es2019/i18n/uk.js +19 -0
  66. package/dist/es2019/i18n/vi.js +19 -0
  67. package/dist/es2019/i18n/zh.js +19 -0
  68. package/dist/es2019/i18n/zh_TW.js +19 -0
  69. package/dist/es2019/lists/analytics.js +36 -0
  70. package/dist/es2019/lists/indentation.js +18 -0
  71. package/dist/es2019/lists/index.js +6 -0
  72. package/dist/es2019/lists/node.js +97 -0
  73. package/dist/es2019/lists/replace-content.js +18 -0
  74. package/dist/es2019/lists/selection.js +53 -0
  75. package/dist/es2019/mark/commands.js +205 -0
  76. package/dist/es2019/mark/index.js +1 -0
  77. package/dist/es2019/messages/full-page.js +18 -0
  78. package/dist/es2019/messages/index.js +1 -0
  79. package/dist/es2019/monitoring/error.js +1 -1
  80. package/dist/es2019/node-width/index.js +7 -0
  81. package/dist/es2019/ui/DropList/index.js +1 -1
  82. package/dist/es2019/ui/Toolbar/index.js +1 -0
  83. package/dist/es2019/ui/index.js +2 -1
  84. package/dist/es2019/ui-menu/DropdownMenu/index.js +16 -2
  85. package/dist/es2019/ui-menu/ToolbarArrowKeyNavigationProvider/index.js +209 -0
  86. package/dist/es2019/ui-menu/index.js +5 -4
  87. package/dist/es2019/utils/commands.js +106 -2
  88. package/dist/es2019/utils/document.js +25 -1
  89. package/dist/es2019/utils/index.js +3 -2
  90. package/dist/es2019/utils/prosemirror/autojoin.js +57 -0
  91. package/dist/es2019/version.json +1 -1
  92. package/dist/esm/i18n/cs.js +19 -0
  93. package/dist/esm/i18n/da.js +19 -0
  94. package/dist/esm/i18n/de.js +19 -0
  95. package/dist/esm/i18n/es.js +19 -0
  96. package/dist/esm/i18n/fi.js +19 -0
  97. package/dist/esm/i18n/fr.js +19 -0
  98. package/dist/esm/i18n/hu.js +19 -0
  99. package/dist/esm/i18n/it.js +19 -0
  100. package/dist/esm/i18n/ja.js +19 -0
  101. package/dist/esm/i18n/ko.js +19 -0
  102. package/dist/esm/i18n/nb.js +19 -0
  103. package/dist/esm/i18n/nl.js +19 -0
  104. package/dist/esm/i18n/pl.js +19 -0
  105. package/dist/esm/i18n/pt_BR.js +19 -0
  106. package/dist/esm/i18n/ru.js +19 -0
  107. package/dist/esm/i18n/sv.js +19 -0
  108. package/dist/esm/i18n/th.js +19 -0
  109. package/dist/esm/i18n/tr.js +19 -0
  110. package/dist/esm/i18n/uk.js +19 -0
  111. package/dist/esm/i18n/vi.js +19 -0
  112. package/dist/esm/i18n/zh.js +19 -0
  113. package/dist/esm/i18n/zh_TW.js +19 -0
  114. package/dist/esm/lists/analytics.js +32 -0
  115. package/dist/esm/lists/indentation.js +17 -0
  116. package/dist/esm/lists/index.js +6 -0
  117. package/dist/esm/lists/node.js +87 -0
  118. package/dist/esm/lists/replace-content.js +17 -0
  119. package/dist/esm/lists/selection.js +50 -0
  120. package/dist/esm/mark/commands.js +190 -0
  121. package/dist/esm/mark/index.js +1 -0
  122. package/dist/esm/messages/full-page.js +18 -0
  123. package/dist/esm/messages/index.js +1 -0
  124. package/dist/esm/monitoring/error.js +1 -1
  125. package/dist/esm/node-width/index.js +7 -0
  126. package/dist/esm/ui/DropList/index.js +1 -1
  127. package/dist/esm/ui/Toolbar/index.js +1 -0
  128. package/dist/esm/ui/index.js +2 -1
  129. package/dist/esm/ui-menu/DropdownMenu/index.js +15 -2
  130. package/dist/esm/ui-menu/ToolbarArrowKeyNavigationProvider/index.js +207 -0
  131. package/dist/esm/ui-menu/index.js +5 -4
  132. package/dist/esm/utils/commands.js +104 -2
  133. package/dist/esm/utils/document.js +25 -1
  134. package/dist/esm/utils/index.js +3 -2
  135. package/dist/esm/utils/prosemirror/autojoin.js +63 -0
  136. package/dist/esm/version.json +1 -1
  137. package/dist/types/i18n/cs.d.ts +19 -0
  138. package/dist/types/i18n/da.d.ts +19 -0
  139. package/dist/types/i18n/de.d.ts +19 -0
  140. package/dist/types/i18n/es.d.ts +19 -0
  141. package/dist/types/i18n/fi.d.ts +19 -0
  142. package/dist/types/i18n/fr.d.ts +19 -0
  143. package/dist/types/i18n/hu.d.ts +19 -0
  144. package/dist/types/i18n/it.d.ts +19 -0
  145. package/dist/types/i18n/ja.d.ts +19 -0
  146. package/dist/types/i18n/ko.d.ts +19 -0
  147. package/dist/types/i18n/nb.d.ts +19 -0
  148. package/dist/types/i18n/nl.d.ts +19 -0
  149. package/dist/types/i18n/pl.d.ts +19 -0
  150. package/dist/types/i18n/pt_BR.d.ts +19 -0
  151. package/dist/types/i18n/ru.d.ts +19 -0
  152. package/dist/types/i18n/sv.d.ts +19 -0
  153. package/dist/types/i18n/th.d.ts +19 -0
  154. package/dist/types/i18n/tr.d.ts +19 -0
  155. package/dist/types/i18n/uk.d.ts +19 -0
  156. package/dist/types/i18n/vi.d.ts +19 -0
  157. package/dist/types/i18n/zh.d.ts +19 -0
  158. package/dist/types/i18n/zh_TW.d.ts +19 -0
  159. package/dist/types/lists/analytics.d.ts +4 -0
  160. package/dist/types/lists/indentation.d.ts +5 -0
  161. package/dist/types/lists/index.d.ts +6 -0
  162. package/dist/types/lists/node.d.ts +18 -0
  163. package/dist/types/lists/replace-content.d.ts +8 -0
  164. package/dist/types/lists/selection.d.ts +13 -0
  165. package/dist/types/mark/commands.d.ts +18 -0
  166. package/dist/types/mark/index.d.ts +1 -0
  167. package/dist/types/messages/full-page.d.ts +17 -0
  168. package/dist/types/messages/index.d.ts +1 -0
  169. package/dist/types/node-width/index.d.ts +1 -0
  170. package/dist/types/ui/Toolbar/index.d.ts +5 -0
  171. package/dist/types/ui/index.d.ts +2 -0
  172. package/dist/types/ui-menu/DropdownMenu/index.d.ts +2 -1
  173. package/dist/types/ui-menu/ToolbarArrowKeyNavigationProvider/index.d.ts +30 -0
  174. package/dist/types/ui-menu/index.d.ts +7 -6
  175. package/dist/types/utils/commands.d.ts +36 -2
  176. package/dist/types/utils/document.d.ts +4 -0
  177. package/dist/types/utils/index.d.ts +4 -2
  178. package/dist/types/utils/prosemirror/autojoin.d.ts +13 -0
  179. package/dist/types-ts4.5/i18n/cs.d.ts +19 -0
  180. package/dist/types-ts4.5/i18n/da.d.ts +19 -0
  181. package/dist/types-ts4.5/i18n/de.d.ts +19 -0
  182. package/dist/types-ts4.5/i18n/es.d.ts +19 -0
  183. package/dist/types-ts4.5/i18n/fi.d.ts +19 -0
  184. package/dist/types-ts4.5/i18n/fr.d.ts +19 -0
  185. package/dist/types-ts4.5/i18n/hu.d.ts +19 -0
  186. package/dist/types-ts4.5/i18n/it.d.ts +19 -0
  187. package/dist/types-ts4.5/i18n/ja.d.ts +19 -0
  188. package/dist/types-ts4.5/i18n/ko.d.ts +19 -0
  189. package/dist/types-ts4.5/i18n/nb.d.ts +19 -0
  190. package/dist/types-ts4.5/i18n/nl.d.ts +19 -0
  191. package/dist/types-ts4.5/i18n/pl.d.ts +19 -0
  192. package/dist/types-ts4.5/i18n/pt_BR.d.ts +19 -0
  193. package/dist/types-ts4.5/i18n/ru.d.ts +19 -0
  194. package/dist/types-ts4.5/i18n/sv.d.ts +19 -0
  195. package/dist/types-ts4.5/i18n/th.d.ts +19 -0
  196. package/dist/types-ts4.5/i18n/tr.d.ts +19 -0
  197. package/dist/types-ts4.5/i18n/uk.d.ts +19 -0
  198. package/dist/types-ts4.5/i18n/vi.d.ts +19 -0
  199. package/dist/types-ts4.5/i18n/zh.d.ts +19 -0
  200. package/dist/types-ts4.5/i18n/zh_TW.d.ts +19 -0
  201. package/dist/types-ts4.5/lists/analytics.d.ts +4 -0
  202. package/dist/types-ts4.5/lists/indentation.d.ts +5 -0
  203. package/dist/types-ts4.5/lists/index.d.ts +6 -0
  204. package/dist/types-ts4.5/lists/node.d.ts +18 -0
  205. package/dist/types-ts4.5/lists/replace-content.d.ts +8 -0
  206. package/dist/types-ts4.5/lists/selection.d.ts +13 -0
  207. package/dist/types-ts4.5/mark/commands.d.ts +18 -0
  208. package/dist/types-ts4.5/mark/index.d.ts +1 -0
  209. package/dist/types-ts4.5/messages/full-page.d.ts +17 -0
  210. package/dist/types-ts4.5/messages/index.d.ts +1 -0
  211. package/dist/types-ts4.5/node-width/index.d.ts +1 -0
  212. package/dist/types-ts4.5/ui/Toolbar/index.d.ts +5 -0
  213. package/dist/types-ts4.5/ui/index.d.ts +2 -0
  214. package/dist/types-ts4.5/ui-menu/DropdownMenu/index.d.ts +2 -1
  215. package/dist/types-ts4.5/ui-menu/ToolbarArrowKeyNavigationProvider/index.d.ts +30 -0
  216. package/dist/types-ts4.5/ui-menu/index.d.ts +7 -6
  217. package/dist/types-ts4.5/utils/commands.d.ts +42 -2
  218. package/dist/types-ts4.5/utils/document.d.ts +4 -0
  219. package/dist/types-ts4.5/utils/index.d.ts +4 -2
  220. package/dist/types-ts4.5/utils/prosemirror/autojoin.d.ts +13 -0
  221. package/lists/package.json +15 -0
  222. package/mark/package.json +15 -0
  223. package/package.json +6 -3
@@ -0,0 +1,97 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.JoinDirection = void 0;
7
+ exports.isListNodeValidContent = isListNodeValidContent;
8
+ exports.joinSiblingLists = void 0;
9
+ var _model = require("@atlaskit/editor-prosemirror/model");
10
+ var _utils = require("../utils");
11
+ function isListNodeValidContent(node) {
12
+ var bulletList = node.type.schema.nodes.bulletList;
13
+ if (!bulletList) {
14
+ return false;
15
+ }
16
+ var listFragment = _model.Fragment.from(bulletList.createAndFill());
17
+ return !(0, _utils.isListItemNode)(node) && node.type.validContent(listFragment);
18
+ }
19
+ var JoinDirection = /*#__PURE__*/function (JoinDirection) {
20
+ JoinDirection[JoinDirection["LEFT"] = 1] = "LEFT";
21
+ JoinDirection[JoinDirection["RIGHT"] = -1] = "RIGHT";
22
+ return JoinDirection;
23
+ }({});
24
+ exports.JoinDirection = JoinDirection;
25
+ var joinSiblingLists = function joinSiblingLists(_ref) {
26
+ var tr = _ref.tr,
27
+ direction = _ref.direction,
28
+ forceListType = _ref.forceListType;
29
+ var result = {
30
+ orderedList: 0,
31
+ bulletList: 0
32
+ };
33
+ var doc = tr.doc,
34
+ _tr$selection = tr.selection,
35
+ $from = _tr$selection.$from,
36
+ $to = _tr$selection.$to,
37
+ selection = tr.selection;
38
+ var range = $from.blockRange($to, isListNodeValidContent);
39
+ if (!range) {
40
+ return result;
41
+ }
42
+ var rootListNode = doc.nodeAt(range.start);
43
+ var from = (0, _utils.isListNode)(rootListNode) ? range.start : 0;
44
+ var to = (0, _utils.isListNode)(rootListNode) ? range.end : tr.doc.content.size;
45
+ var joins = [];
46
+ doc.nodesBetween(from, to, function (node, pos, parent) {
47
+ var resolvedPos = doc.resolve(pos);
48
+ var nodeBefore = resolvedPos.nodeBefore,
49
+ nodeAfter = resolvedPos.nodeAfter;
50
+ if (!nodeBefore || !nodeAfter || !(0, _utils.isListNode)(nodeBefore) || !(0, _utils.isListNode)(nodeAfter)) {
51
+ return;
52
+ }
53
+ var isNestedList = (0, _utils.isListItemNode)(parent);
54
+ if (!isNestedList && nodeBefore.type !== nodeAfter.type && !forceListType) {
55
+ return;
56
+ }
57
+ var index = resolvedPos.index();
58
+ var positionPreviousNode = resolvedPos.posAtIndex(index - 1);
59
+ var positionCurrentNode = resolvedPos.posAtIndex(index);
60
+
61
+ // If the previous node is part of the selection, OR
62
+ // If the previous node is not part of the selection and the previous node has the same list type that we’re converting to
63
+ var joinBefore = positionPreviousNode >= from || nodeBefore.type === forceListType;
64
+ if (forceListType) {
65
+ if (joinBefore) {
66
+ tr.setNodeMarkup(positionPreviousNode, forceListType);
67
+ }
68
+ tr.setNodeMarkup(positionCurrentNode, forceListType);
69
+ }
70
+ if (isNestedList && nodeBefore.type !== nodeAfter.type) {
71
+ var nodeType = direction === JoinDirection.RIGHT ? nodeAfter.type : nodeBefore.type;
72
+ tr.setNodeMarkup(positionPreviousNode, nodeType);
73
+ }
74
+ if (joinBefore) {
75
+ joins.push(pos);
76
+ }
77
+ });
78
+ if (selection.empty && rootListNode && (0, _utils.isListNode)(rootListNode)) {
79
+ var resolvedPos = doc.resolve(range.start + rootListNode.nodeSize);
80
+ var nodeBefore = resolvedPos.nodeBefore,
81
+ nodeAfter = resolvedPos.nodeAfter;
82
+ if (nodeBefore && nodeAfter && (0, _utils.isListNode)(nodeBefore) && (0, _utils.isListNode)(nodeAfter) && nodeAfter.type === nodeBefore.type) {
83
+ joins.push(resolvedPos.pos);
84
+ }
85
+ }
86
+ for (var i = joins.length - 1; i >= 0; i--) {
87
+ var listNode = tr.doc.nodeAt(joins[i]);
88
+ var listName = listNode === null || listNode === void 0 ? void 0 : listNode.type.name;
89
+ if (listName && (listName === 'orderedList' || listName === 'bulletList')) {
90
+ var amount = result[listName] || 0;
91
+ result[listName] = amount + 1;
92
+ }
93
+ tr.join(joins[i]);
94
+ }
95
+ return result;
96
+ };
97
+ exports.joinSiblingLists = joinSiblingLists;
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.moveTargetIntoList = void 0;
7
+ var _transform = require("@atlaskit/editor-prosemirror/transform");
8
+ var moveTargetIntoList = function moveTargetIntoList(_ref) {
9
+ var _$target$nodeAfter;
10
+ var insertPosition = _ref.insertPosition,
11
+ $target = _ref.$target;
12
+ // take the text content of the paragraph and insert after the paragraph up until before the the cut
13
+ var from = insertPosition;
14
+ var to = $target.pos + (((_$target$nodeAfter = $target.nodeAfter) === null || _$target$nodeAfter === void 0 ? void 0 : _$target$nodeAfter.nodeSize) || 0); //$cut.pos + $cut.nodeAfter.nodeSize;
15
+ var gapFrom = $target.posAtIndex(0, $target.depth + 1); // start pos of the child
16
+ var gapTo = $target.doc.resolve(gapFrom).end(); // end pos of the paragraph
17
+
18
+ if (gapTo - gapFrom === 0) {
19
+ return new _transform.ReplaceStep(from, to, $target.doc.slice(insertPosition, $target.pos));
20
+ }
21
+ var step = new _transform.ReplaceAroundStep(from, to, gapFrom, gapTo, $target.doc.slice(insertPosition, $target.pos), 0, true);
22
+ return step;
23
+ };
24
+ exports.moveTargetIntoList = moveTargetIntoList;
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.numberNestedLists = exports.normalizeListItemsSelection = exports.getListItemAttributes = void 0;
7
+ var _state = require("@atlaskit/editor-prosemirror/state");
8
+ var _utils = require("@atlaskit/editor-prosemirror/utils");
9
+ var _utils2 = require("../utils");
10
+ var numberNestedLists = function numberNestedLists(resolvedPos) {
11
+ var count = 0;
12
+ for (var i = resolvedPos.depth - 1; i > 0; i--) {
13
+ var node = resolvedPos.node(i);
14
+ if ((0, _utils2.isListNode)(node)) {
15
+ count += 1;
16
+ }
17
+ }
18
+ return count;
19
+ };
20
+ exports.numberNestedLists = numberNestedLists;
21
+ var getListItemAttributes = function getListItemAttributes($pos) {
22
+ var indentLevel = numberNestedLists($pos) - 1;
23
+ var itemAtPos = (0, _utils.findParentNodeClosestToPos)($pos, _utils2.isListItemNode);
24
+
25
+ // Get the index of the current item relative to parent (parent is at item depth - 1)
26
+ var itemIndex = $pos.index(itemAtPos ? itemAtPos.depth - 1 : undefined);
27
+ return {
28
+ indentLevel: indentLevel,
29
+ itemIndex: itemIndex
30
+ };
31
+ };
32
+ exports.getListItemAttributes = getListItemAttributes;
33
+ var normalizeListItemsSelection = function normalizeListItemsSelection(_ref) {
34
+ var selection = _ref.selection,
35
+ doc = _ref.doc;
36
+ if (selection.empty) {
37
+ return selection;
38
+ }
39
+ var $from = selection.$from,
40
+ $to = selection.$to;
41
+ if (selection instanceof _state.NodeSelection) {
42
+ var _head = resolvePositionToStartOfListItem($from);
43
+ return new _state.TextSelection(_head, _head);
44
+ }
45
+ var head = resolvePositionToStartOfListItem($from);
46
+ var anchor = resolvePositionToEndOfListItem($to);
47
+ return new _state.TextSelection(anchor, head);
48
+ };
49
+ exports.normalizeListItemsSelection = normalizeListItemsSelection;
50
+ var resolvePositionToStartOfListItem = function resolvePositionToStartOfListItem($pos) {
51
+ var fromRange = $pos.blockRange($pos, _utils2.isListItemNode);
52
+ var fromPosition = fromRange && $pos.textOffset === 0 && fromRange.end - 1 === $pos.pos ? _state.Selection.near($pos.doc.resolve(fromRange.end + 1), 1).$from : $pos;
53
+ return fromPosition;
54
+ };
55
+ var resolvePositionToEndOfListItem = function resolvePositionToEndOfListItem($pos) {
56
+ var toRange = $pos.blockRange($pos, _utils2.isListItemNode);
57
+ var toPosition = toRange && $pos.textOffset === 0 && toRange.start + 1 === $pos.pos ? _state.Selection.near($pos.doc.resolve(toRange.start - 1), -1).$to : $pos;
58
+ return toPosition;
59
+ };
@@ -0,0 +1,201 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.applyMarkOnRange = void 0;
7
+ exports.filterChildrenBetween = filterChildrenBetween;
8
+ exports.transformSmartCharsMentionsAndEmojis = exports.toggleMark = void 0;
9
+ var _state = require("@atlaskit/editor-prosemirror/state");
10
+ var _cellSelection = require("@atlaskit/editor-tables/cell-selection");
11
+ // eslint-disable-next-line no-duplicate-imports
12
+
13
+ var SMART_TO_ASCII = {
14
+ '…': '...',
15
+ '→': '->',
16
+ '←': '<-',
17
+ '–': '--',
18
+ '“': '"',
19
+ '”': '"',
20
+ '‘': "'",
21
+ '’': "'"
22
+ };
23
+ var FIND_SMART_CHAR = new RegExp("[".concat(Object.keys(SMART_TO_ASCII).join(''), "]"), 'g');
24
+ var isNodeTextBlock = function isNodeTextBlock(schema) {
25
+ var _schema$nodes = schema.nodes,
26
+ mention = _schema$nodes.mention,
27
+ text = _schema$nodes.text,
28
+ emoji = _schema$nodes.emoji;
29
+ return function (node, _, parent) {
30
+ if (node.type === mention || node.type === emoji || node.type === text) {
31
+ return parent === null || parent === void 0 ? void 0 : parent.isTextblock;
32
+ }
33
+ return;
34
+ };
35
+ };
36
+ var replaceSmartCharsToAscii = function replaceSmartCharsToAscii(position, textContent, tr) {
37
+ var schema = tr.doc.type.schema;
38
+ var match;
39
+ while (match = FIND_SMART_CHAR.exec(textContent)) {
40
+ var _match = match,
41
+ smartChar = _match[0],
42
+ offset = _match.index;
43
+ var replacePos = tr.mapping.map(position + offset);
44
+ var replacementText = schema.text(SMART_TO_ASCII[smartChar]);
45
+ tr.replaceWith(replacePos, replacePos + smartChar.length, replacementText);
46
+ }
47
+ };
48
+ var replaceMentionOrEmojiForTextContent = function replaceMentionOrEmojiForTextContent(position, nodeSize, textContent, tr) {
49
+ var currentPos = tr.mapping.map(position);
50
+ var schema = tr.doc.type.schema;
51
+ tr.replaceWith(currentPos, currentPos + nodeSize, schema.text(textContent));
52
+ };
53
+ function filterChildrenBetween(doc, from, to, predicate) {
54
+ var results = [];
55
+ doc.nodesBetween(from, to, function (node, pos, parent) {
56
+ if (predicate(node, pos, parent)) {
57
+ results.push({
58
+ node: node,
59
+ pos: pos
60
+ });
61
+ }
62
+ });
63
+ return results;
64
+ }
65
+ var transformSmartCharsMentionsAndEmojis = function transformSmartCharsMentionsAndEmojis(from, to, tr) {
66
+ var schema = tr.doc.type.schema;
67
+ var _schema$nodes2 = schema.nodes,
68
+ mention = _schema$nodes2.mention,
69
+ text = _schema$nodes2.text,
70
+ emoji = _schema$nodes2.emoji;
71
+ // Traverse through all the nodes within the range and replace them with their plaintext counterpart
72
+ var children = filterChildrenBetween(tr.doc, from, to, isNodeTextBlock(schema));
73
+ children.forEach(function (_ref) {
74
+ var node = _ref.node,
75
+ pos = _ref.pos;
76
+ if (node.type === mention || node.type === emoji) {
77
+ // Convert gracefully when no text found, ProseMirror will blow up if you try to create a node with an empty string or undefined
78
+ var replacementText = node.attrs.text;
79
+ if (typeof replacementText === 'undefined' || replacementText === '') {
80
+ replacementText = "".concat(node.type.name, " text missing");
81
+ }
82
+ replaceMentionOrEmojiForTextContent(pos, node.nodeSize, replacementText, tr);
83
+ } else if (node.type === text && node.text) {
84
+ var replacePosition = pos > from ? pos : from;
85
+ var textToReplace = pos > from ? node.text : node.text.substr(from - pos);
86
+ replaceSmartCharsToAscii(replacePosition, textToReplace, tr);
87
+ }
88
+ });
89
+ };
90
+ exports.transformSmartCharsMentionsAndEmojis = transformSmartCharsMentionsAndEmojis;
91
+ var applyMarkOnRange = function applyMarkOnRange(from, to, removeMark, mark, tr) {
92
+ var schema = tr.doc.type.schema;
93
+ var code = schema.marks.code;
94
+ if (mark.type === code) {
95
+ transformSmartCharsMentionsAndEmojis(from, to, tr);
96
+ }
97
+ tr.doc.nodesBetween(tr.mapping.map(from), tr.mapping.map(to), function (node, pos) {
98
+ if (!node.isText) {
99
+ return true;
100
+ }
101
+
102
+ // This is an issue when the user selects some text.
103
+ // We need to check if the current node position is less than the range selection from.
104
+ // If it’s true, that means we should apply the mark using the range selection,
105
+ // not the current node position.
106
+ var nodeBetweenFrom = Math.max(pos, tr.mapping.map(from));
107
+ var nodeBetweenTo = Math.min(pos + node.nodeSize, tr.mapping.map(to));
108
+ if (removeMark) {
109
+ tr.removeMark(nodeBetweenFrom, nodeBetweenTo, mark);
110
+ } else {
111
+ tr.addMark(nodeBetweenFrom, nodeBetweenTo, mark);
112
+ }
113
+ return true;
114
+ });
115
+ return tr;
116
+ };
117
+ exports.applyMarkOnRange = applyMarkOnRange;
118
+ var entireSelectionContainsMark = function entireSelectionContainsMark(mark, doc, fromPos, toPos) {
119
+ var onlyContainsMark = true;
120
+ doc.nodesBetween(fromPos, toPos, function (node) {
121
+ // Skip recursion once we've found text which doesn't include the mark
122
+ if (!onlyContainsMark) {
123
+ return false;
124
+ }
125
+ if (node.isText) {
126
+ onlyContainsMark && (onlyContainsMark = mark.isInSet(node.marks));
127
+ }
128
+ });
129
+ return onlyContainsMark;
130
+ };
131
+ var toggleMarkInRange = function toggleMarkInRange(mark) {
132
+ return function (state, dispatch) {
133
+ var tr = state.tr;
134
+ if (state.selection instanceof _cellSelection.CellSelection) {
135
+ var removeMark = true;
136
+ var cells = [];
137
+ state.selection.forEachCell(function (cell, cellPos) {
138
+ cells.push({
139
+ node: cell,
140
+ pos: cellPos
141
+ });
142
+ var from = cellPos;
143
+ var to = cellPos + cell.nodeSize;
144
+ removeMark && (removeMark = entireSelectionContainsMark(mark, state.doc, from, to));
145
+ });
146
+ for (var i = cells.length - 1; i >= 0; i--) {
147
+ var cell = cells[i];
148
+ var from = cell.pos;
149
+ var to = from + cell.node.nodeSize;
150
+ applyMarkOnRange(from, to, removeMark, mark, tr);
151
+ }
152
+ } else {
153
+ var _state$selection = state.selection,
154
+ $from = _state$selection.$from,
155
+ $to = _state$selection.$to;
156
+ // We decide to remove the mark only if the entire selection contains the mark
157
+ // Examples with *bold* text
158
+ // Scenario 1: Selection contains both bold and non-bold text -> bold entire selection
159
+ // Scenario 2: Selection contains only bold text -> un-bold entire selection
160
+ // Scenario 3: Selection contains no bold text -> bold entire selection
161
+ var _removeMark = entireSelectionContainsMark(mark, state.doc, $from.pos, $to.pos);
162
+ applyMarkOnRange($from.pos, $to.pos, _removeMark, mark, tr);
163
+ }
164
+ if (tr.docChanged) {
165
+ if (dispatch) {
166
+ dispatch(tr);
167
+ }
168
+ return true;
169
+ }
170
+ return false;
171
+ };
172
+ };
173
+
174
+ /**
175
+ * A wrapper over the default toggleMark, except when we have a selection
176
+ * we only toggle marks on text nodes rather than inline nodes.
177
+ * @param markType
178
+ * @param attrs
179
+ */
180
+ var toggleMark = function toggleMark(markType, attrs) {
181
+ return function (state, dispatch) {
182
+ var mark = markType.create(attrs);
183
+
184
+ // For cursor selections we can use the default behaviour.
185
+ if (state.selection instanceof _state.TextSelection && state.selection.$cursor) {
186
+ var tr = state.tr;
187
+ if (mark.isInSet(state.storedMarks || state.selection.$cursor.marks())) {
188
+ tr.removeStoredMark(mark);
189
+ } else {
190
+ tr.addStoredMark(mark);
191
+ }
192
+ if (dispatch) {
193
+ dispatch(tr);
194
+ return true;
195
+ }
196
+ return false;
197
+ }
198
+ return toggleMarkInRange(mark)(state, dispatch);
199
+ };
200
+ };
201
+ exports.toggleMark = toggleMark;
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "applyMarkOnRange", {
7
+ enumerable: true,
8
+ get: function get() {
9
+ return _commands.applyMarkOnRange;
10
+ }
11
+ });
12
+ Object.defineProperty(exports, "filterChildrenBetween", {
13
+ enumerable: true,
14
+ get: function get() {
15
+ return _commands.filterChildrenBetween;
16
+ }
17
+ });
18
+ Object.defineProperty(exports, "toggleMark", {
19
+ enumerable: true,
20
+ get: function get() {
21
+ return _commands.toggleMark;
22
+ }
23
+ });
24
+ Object.defineProperty(exports, "transformSmartCharsMentionsAndEmojis", {
25
+ enumerable: true,
26
+ get: function get() {
27
+ return _commands.transformSmartCharsMentionsAndEmojis;
28
+ }
29
+ });
30
+ var _commands = require("./commands");
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.messages = void 0;
7
+ var _reactIntlNext = require("react-intl-next");
8
+ var messages = (0, _reactIntlNext.defineMessages)({
9
+ toolbarLabel: {
10
+ id: 'fabric.editor.toolbarLabel',
11
+ defaultMessage: 'Editor toolbar',
12
+ description: 'Label for the ARIA region landmark'
13
+ },
14
+ pageActionsLabel: {
15
+ id: 'fabric.editor.pageActionsLabel',
16
+ defaultMessage: 'Page actions',
17
+ description: 'Label for the ARIA region landmark'
18
+ },
19
+ editableContentLabel: {
20
+ id: 'fabric.editor.editableContentLabel',
21
+ defaultMessage: 'Editable content',
22
+ description: 'Label for the ARIA region landmark'
23
+ }
24
+ });
25
+ exports.messages = messages;
@@ -22,6 +22,12 @@ Object.defineProperty(exports, "codeBlockButtonMessages", {
22
22
  }
23
23
  });
24
24
  exports.default = void 0;
25
+ Object.defineProperty(exports, "fullPageMessages", {
26
+ enumerable: true,
27
+ get: function get() {
28
+ return _fullPage.messages;
29
+ }
30
+ });
25
31
  Object.defineProperty(exports, "linkMessages", {
26
32
  enumerable: true,
27
33
  get: function get() {
@@ -61,6 +67,7 @@ var _codeBlockButton = require("./codeBlockButton");
61
67
  var _insertBlock = require("./insert-block");
62
68
  var _mediaAndEmbedToolbar = require("./media-and-embed-toolbar");
63
69
  var _card = require("./card");
70
+ var _fullPage = require("./full-page");
64
71
  var _default = (0, _reactIntlNext.defineMessages)({
65
72
  layoutFixedWidth: {
66
73
  id: 'fabric.editor.layoutFixedWidth',
@@ -16,7 +16,7 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
16
16
  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; }
17
17
  var SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
18
18
  var packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
19
- var packageVersion = "74.29.3";
19
+ var packageVersion = "74.31.0";
20
20
  var sanitiseSentryEvents = function sanitiseSentryEvents(data, _hint) {
21
21
  // Remove URL as it has UGC
22
22
  // TODO: Sanitise the URL instead of just removing it
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.layoutToWidth = exports.getTableContainerWidth = exports.getParentNodeWidth = void 0;
6
+ exports.layoutToWidth = exports.getTableWidthWithNumberColumn = exports.getTableContainerWidth = exports.getParentNodeWidth = void 0;
7
7
  var _utils = require("@atlaskit/editor-prosemirror/utils");
8
8
  var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
9
9
  var _constants = require("@atlaskit/theme/constants");
@@ -110,4 +110,12 @@ var getTableContainerWidth = function getTableContainerWidth(node) {
110
110
  }
111
111
  return layoutToWidth[node.attrs.layout];
112
112
  };
113
- exports.getTableContainerWidth = getTableContainerWidth;
113
+ exports.getTableContainerWidth = getTableContainerWidth;
114
+ var getTableWidthWithNumberColumn = function getTableWidthWithNumberColumn(node, offset) {
115
+ var isNumberColumnEnabled = node.attrs.isNumberColumnEnabled;
116
+ if (isNumberColumnEnabled && offset > 0) {
117
+ return getTableContainerWidth(node) - offset;
118
+ }
119
+ return getTableContainerWidth(node);
120
+ };
121
+ exports.getTableWidthWithNumberColumn = getTableWidthWithNumberColumn;
@@ -24,7 +24,7 @@ var _templateObject, _templateObject2, _templateObject3;
24
24
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
25
25
  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; } } /** @jsx jsx */
26
26
  var packageName = "@atlaskit/editor-common";
27
- var packageVersion = "74.29.3";
27
+ var packageVersion = "74.31.0";
28
28
  var halfFocusRing = 1;
29
29
  var dropOffset = '0, 8';
30
30
  var DropList = /*#__PURE__*/function (_Component) {
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.EDIT_AREA_ID = void 0;
7
+ var EDIT_AREA_ID = 'ak-editor-textarea';
8
+ exports.EDIT_AREA_ID = EDIT_AREA_ID;
@@ -59,6 +59,12 @@ Object.defineProperty(exports, "DEFAULT_IMAGE_WIDTH", {
59
59
  return _MediaSingle.DEFAULT_IMAGE_WIDTH;
60
60
  }
61
61
  });
62
+ Object.defineProperty(exports, "EDIT_AREA_ID", {
63
+ enumerable: true,
64
+ get: function get() {
65
+ return _Toolbar.EDIT_AREA_ID;
66
+ }
67
+ });
62
68
  Object.defineProperty(exports, "ErrorMessage", {
63
69
  enumerable: true,
64
70
  get: function get() {
@@ -405,5 +411,6 @@ var _styled2 = require("./ResizerLegacy/styled");
405
411
  var _styles = require("./PanelTextInput/styles");
406
412
  var _PanelTextInput = _interopRequireDefault(require("./PanelTextInput"));
407
413
  var _announcer = _interopRequireDefault(require("./Announcer/announcer"));
414
+ var _Toolbar = require("./Toolbar");
408
415
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
409
416
  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; }
@@ -5,7 +5,8 @@ var _typeof = require("@babel/runtime/helpers/typeof");
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
- exports.default = void 0;
8
+ exports.default = exports.DropdownMenuWithKeyboardNavigation = void 0;
9
+ var _objectDestructuringEmpty2 = _interopRequireDefault(require("@babel/runtime/helpers/objectDestructuringEmpty"));
9
10
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
10
11
  var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
11
12
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
@@ -26,6 +27,7 @@ var _colors = require("@atlaskit/theme/colors");
26
27
  var _components = require("@atlaskit/theme/components");
27
28
  var _tooltip = _interopRequireDefault(require("@atlaskit/tooltip"));
28
29
  var _styles = require("../../styles");
30
+ var _ToolbarArrowKeyNavigationProvider = require("../../ui-menu/ToolbarArrowKeyNavigationProvider");
29
31
  var _uiReact = require("../../ui-react");
30
32
  var _DropList = _interopRequireDefault(require("../../ui/DropList"));
31
33
  var _Popup = _interopRequireDefault(require("../../ui/Popup"));
@@ -327,4 +329,16 @@ function DropdownMenuItem(_ref) {
327
329
  }, dropListItem);
328
330
  }
329
331
  return dropListItem;
330
- }
332
+ }
333
+ var DropdownMenuWithKeyboardNavigation = /*#__PURE__*/_react.default.memo(function (_ref2) {
334
+ var props = (0, _extends2.default)({}, ((0, _objectDestructuringEmpty2.default)(_ref2), _ref2));
335
+ var keyDownHandlerContext = (0, _react.useContext)(_ToolbarArrowKeyNavigationProvider.KeyDownHandlerContext);
336
+ //This context is to handle the tab, Arrow Right/Left key events for dropdown.
337
+ //Default context has the void callbacks for above key events
338
+ return (0, _react2.jsx)(DropdownMenuWrapper, (0, _extends2.default)({
339
+ arrowKeyNavigationProviderOptions: _objectSpread(_objectSpread({}, props.arrowKeyNavigationProviderOptions), {}, {
340
+ keyDownHandlerContext: keyDownHandlerContext
341
+ })
342
+ }, props));
343
+ });
344
+ exports.DropdownMenuWithKeyboardNavigation = DropdownMenuWithKeyboardNavigation;