@atlaskit/editor-core 190.1.24 → 190.1.26

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 (103) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/afm-cc/tsconfig.json +0 -12
  3. package/dist/cjs/plugins/index.js +0 -7
  4. package/dist/cjs/presets/default.js +2 -3
  5. package/dist/cjs/ui/ConfigPanel/Fields/ColorPicker.js +13 -0
  6. package/dist/cjs/version-wrapper.js +1 -1
  7. package/dist/es2019/plugins/index.js +0 -1
  8. package/dist/es2019/presets/default.js +1 -1
  9. package/dist/es2019/ui/ConfigPanel/Fields/ColorPicker.js +13 -0
  10. package/dist/es2019/version-wrapper.js +1 -1
  11. package/dist/esm/plugins/index.js +0 -1
  12. package/dist/esm/presets/default.js +1 -1
  13. package/dist/esm/ui/ConfigPanel/Fields/ColorPicker.js +13 -0
  14. package/dist/esm/version-wrapper.js +1 -1
  15. package/dist/types/plugins/index.d.ts +0 -1
  16. package/dist/types/presets/default.d.ts +1 -1
  17. package/dist/types/ui/Appearance/FullPage/StyledComponents.d.ts +2 -2
  18. package/dist/types/ui/ContentStyles/index.d.ts +2 -2
  19. package/dist/types-ts4.5/plugins/index.d.ts +0 -1
  20. package/dist/types-ts4.5/presets/default.d.ts +1 -1
  21. package/dist/types-ts4.5/ui/Appearance/FullPage/StyledComponents.d.ts +2 -2
  22. package/dist/types-ts4.5/ui/ContentStyles/index.d.ts +2 -2
  23. package/package.json +9 -11
  24. package/dist/cjs/plugins/paste/actions.js +0 -12
  25. package/dist/cjs/plugins/paste/commands.js +0 -255
  26. package/dist/cjs/plugins/paste/edge-cases/index.js +0 -88
  27. package/dist/cjs/plugins/paste/edge-cases/lists.js +0 -107
  28. package/dist/cjs/plugins/paste/handlers.js +0 -935
  29. package/dist/cjs/plugins/paste/index.js +0 -14
  30. package/dist/cjs/plugins/paste/plugin.js +0 -43
  31. package/dist/cjs/plugins/paste/plugins/media.js +0 -207
  32. package/dist/cjs/plugins/paste/pm-plugins/analytics.js +0 -376
  33. package/dist/cjs/plugins/paste/pm-plugins/clipboard-text-serializer.js +0 -43
  34. package/dist/cjs/plugins/paste/pm-plugins/main.js +0 -482
  35. package/dist/cjs/plugins/paste/pm-plugins/plugin-factory.js +0 -42
  36. package/dist/cjs/plugins/paste/reducer.js +0 -41
  37. package/dist/cjs/plugins/paste/types.js +0 -5
  38. package/dist/cjs/plugins/paste/util/index.js +0 -214
  39. package/dist/cjs/plugins/paste/util/tinyMCE.js +0 -183
  40. package/dist/es2019/plugins/paste/actions.js +0 -6
  41. package/dist/es2019/plugins/paste/commands.js +0 -235
  42. package/dist/es2019/plugins/paste/edge-cases/index.js +0 -87
  43. package/dist/es2019/plugins/paste/edge-cases/lists.js +0 -113
  44. package/dist/es2019/plugins/paste/handlers.js +0 -915
  45. package/dist/es2019/plugins/paste/index.js +0 -3
  46. package/dist/es2019/plugins/paste/plugin.js +0 -38
  47. package/dist/es2019/plugins/paste/plugins/media.js +0 -204
  48. package/dist/es2019/plugins/paste/pm-plugins/analytics.js +0 -332
  49. package/dist/es2019/plugins/paste/pm-plugins/clipboard-text-serializer.js +0 -37
  50. package/dist/es2019/plugins/paste/pm-plugins/main.js +0 -451
  51. package/dist/es2019/plugins/paste/pm-plugins/plugin-factory.js +0 -30
  52. package/dist/es2019/plugins/paste/reducer.js +0 -32
  53. package/dist/es2019/plugins/paste/types.js +0 -1
  54. package/dist/es2019/plugins/paste/util/index.js +0 -209
  55. package/dist/es2019/plugins/paste/util/tinyMCE.js +0 -168
  56. package/dist/esm/plugins/paste/actions.js +0 -6
  57. package/dist/esm/plugins/paste/commands.js +0 -248
  58. package/dist/esm/plugins/paste/edge-cases/index.js +0 -81
  59. package/dist/esm/plugins/paste/edge-cases/lists.js +0 -98
  60. package/dist/esm/plugins/paste/handlers.js +0 -914
  61. package/dist/esm/plugins/paste/index.js +0 -3
  62. package/dist/esm/plugins/paste/plugin.js +0 -37
  63. package/dist/esm/plugins/paste/plugins/media.js +0 -199
  64. package/dist/esm/plugins/paste/pm-plugins/analytics.js +0 -364
  65. package/dist/esm/plugins/paste/pm-plugins/clipboard-text-serializer.js +0 -37
  66. package/dist/esm/plugins/paste/pm-plugins/main.js +0 -469
  67. package/dist/esm/plugins/paste/pm-plugins/plugin-factory.js +0 -36
  68. package/dist/esm/plugins/paste/reducer.js +0 -34
  69. package/dist/esm/plugins/paste/types.js +0 -1
  70. package/dist/esm/plugins/paste/util/index.js +0 -194
  71. package/dist/esm/plugins/paste/util/tinyMCE.js +0 -176
  72. package/dist/types/plugins/paste/actions.d.ts +0 -21
  73. package/dist/types/plugins/paste/commands.d.ts +0 -30
  74. package/dist/types/plugins/paste/edge-cases/index.d.ts +0 -11
  75. package/dist/types/plugins/paste/edge-cases/lists.d.ts +0 -18
  76. package/dist/types/plugins/paste/handlers.d.ts +0 -55
  77. package/dist/types/plugins/paste/index.d.ts +0 -4
  78. package/dist/types/plugins/paste/plugin.d.ts +0 -2
  79. package/dist/types/plugins/paste/plugins/media.d.ts +0 -23
  80. package/dist/types/plugins/paste/pm-plugins/analytics.d.ts +0 -44
  81. package/dist/types/plugins/paste/pm-plugins/clipboard-text-serializer.d.ts +0 -13
  82. package/dist/types/plugins/paste/pm-plugins/main.d.ts +0 -12
  83. package/dist/types/plugins/paste/pm-plugins/plugin-factory.d.ts +0 -3
  84. package/dist/types/plugins/paste/reducer.d.ts +0 -3
  85. package/dist/types/plugins/paste/types.d.ts +0 -1
  86. package/dist/types/plugins/paste/util/index.d.ts +0 -21
  87. package/dist/types/plugins/paste/util/tinyMCE.d.ts +0 -32
  88. package/dist/types-ts4.5/plugins/paste/actions.d.ts +0 -21
  89. package/dist/types-ts4.5/plugins/paste/commands.d.ts +0 -30
  90. package/dist/types-ts4.5/plugins/paste/edge-cases/index.d.ts +0 -11
  91. package/dist/types-ts4.5/plugins/paste/edge-cases/lists.d.ts +0 -18
  92. package/dist/types-ts4.5/plugins/paste/handlers.d.ts +0 -55
  93. package/dist/types-ts4.5/plugins/paste/index.d.ts +0 -4
  94. package/dist/types-ts4.5/plugins/paste/plugin.d.ts +0 -2
  95. package/dist/types-ts4.5/plugins/paste/plugins/media.d.ts +0 -23
  96. package/dist/types-ts4.5/plugins/paste/pm-plugins/analytics.d.ts +0 -44
  97. package/dist/types-ts4.5/plugins/paste/pm-plugins/clipboard-text-serializer.d.ts +0 -13
  98. package/dist/types-ts4.5/plugins/paste/pm-plugins/main.d.ts +0 -12
  99. package/dist/types-ts4.5/plugins/paste/pm-plugins/plugin-factory.d.ts +0 -3
  100. package/dist/types-ts4.5/plugins/paste/reducer.d.ts +0 -3
  101. package/dist/types-ts4.5/plugins/paste/types.d.ts +0 -1
  102. package/dist/types-ts4.5/plugins/paste/util/index.d.ts +0 -21
  103. package/dist/types-ts4.5/plugins/paste/util/tinyMCE.d.ts +0 -32
@@ -1,87 +0,0 @@
1
- import { Selection } from '@atlaskit/editor-prosemirror/state';
2
- import { findParentNodeOfType, safeInsert } from '@atlaskit/editor-prosemirror/utils';
3
- import { insertSliceIntoRangeSelectionInsideList, insertSliceInsideOfPanelNodeSelected, insertSliceAtNodeEdge, insertSliceIntoEmptyNode } from './lists';
4
- import { isListNode } from '@atlaskit/editor-common/utils';
5
- import { ReplaceStep } from '@atlaskit/editor-prosemirror/transform';
6
- import { isSelectionInsidePanel, isEmptyNode, isCursorSelectionAtTextStartOrEnd } from '../util';
7
- export function insertSliceForLists({
8
- tr,
9
- slice,
10
- schema
11
- }) {
12
- var _slice$content$firstC;
13
- const {
14
- selection,
15
- selection: {
16
- $to,
17
- $from
18
- }
19
- } = tr;
20
- const {
21
- $cursor
22
- } = selection;
23
- const panelNode = isSelectionInsidePanel(selection);
24
- const selectionIsInsideList = $from.blockRange($to, isListNode);
25
- if (!$cursor && selectionIsInsideList) {
26
- return insertSliceIntoRangeSelectionInsideList({
27
- tr,
28
- slice
29
- });
30
- }
31
-
32
- // if inside an empty panel, try and insert content inside it rather than replace it
33
- if (panelNode && isEmptyNode(panelNode) && $from.node() === $to.node()) {
34
- return insertSliceInsideOfPanelNodeSelected(panelNode)({
35
- tr,
36
- slice
37
- });
38
- }
39
- if (!$cursor || selectionIsInsideList) {
40
- return tr.replaceSelection(slice);
41
- }
42
- if (isEmptyNode(tr.doc.resolve($cursor.pos).node())) {
43
- return insertSliceIntoEmptyNode({
44
- tr,
45
- slice
46
- });
47
- }
48
-
49
- // When pasting a single list item into an action or decision, we skip the special "insert at node edge"
50
- // logic so that prosemirror pastes the list's content into the action/decision, rather than
51
- // pasting a whole list node directly after the action/decision item. (But we still preserve the
52
- // existing "insert at" node edge" behaviour if dealing with a list with more than one item, so that
53
- // it still inserts whole list node after the action/decision item).
54
- const pastingIntoActionOrDecision = Boolean(findParentNodeOfType([schema.nodes.taskList, schema.nodes.decisionList])(selection));
55
- const oneListItem = slice.content.childCount === 1 && isListNode(slice.content.firstChild) && ((_slice$content$firstC = slice.content.firstChild) === null || _slice$content$firstC === void 0 ? void 0 : _slice$content$firstC.childCount) === 1;
56
- if (!(pastingIntoActionOrDecision && oneListItem) && isCursorSelectionAtTextStartOrEnd(selection)) {
57
- return insertSliceAtNodeEdge({
58
- tr,
59
- slice
60
- });
61
- }
62
- tr.replaceSelection(slice);
63
- }
64
- export function insertSliceForListsInsideBlockquote({
65
- tr,
66
- slice
67
- }) {
68
- safeInsert(slice.content, tr.selection.$to.pos)(tr).scrollIntoView();
69
- // ProseMirror doesn't give a proper way to tell us where something was inserted.
70
- // However, we can know "how" it inserted something.
71
- //
72
- // So, instead of weird depth calculations, we can use the step produced by the transform.
73
- // For instance:
74
- // The `replaceStep.to and replaceStep.from`, tell us the real position
75
- // where the content will be insert.
76
- // Then, we can use the `tr.mapping.map` to the updated position after the replace operation
77
- const replaceStep = tr.steps[0];
78
- if (!(replaceStep instanceof ReplaceStep)) {
79
- return tr;
80
- }
81
- const nextPosition = tr.mapping.map(replaceStep.to);
82
- // The findFrom will make search for both: TextSelection and NodeSelections.
83
- const nextSelection = Selection.findFrom(tr.doc.resolve(Math.min(nextPosition, tr.doc.content.size)), -1);
84
- if (nextSelection) {
85
- tr.setSelection(nextSelection);
86
- }
87
- }
@@ -1,113 +0,0 @@
1
- import { Fragment } from '@atlaskit/editor-prosemirror/model';
2
- import { TextSelection, NodeSelection } from '@atlaskit/editor-prosemirror/state';
3
- import { Transform } from '@atlaskit/editor-prosemirror/transform';
4
- import { isEmptyParagraph } from '@atlaskit/editor-common/utils';
5
- export function insertSliceIntoEmptyNode({
6
- tr,
7
- slice
8
- }) {
9
- tr.replaceSelection(slice);
10
- }
11
- export function insertSliceAtNodeEdge({
12
- tr,
13
- slice
14
- }) {
15
- const {
16
- selection
17
- } = tr;
18
- const {
19
- $cursor
20
- } = selection;
21
- if (!$cursor) {
22
- return;
23
- }
24
- const position = !$cursor.nodeBefore ? $cursor.before() : $cursor.after();
25
- tr.replaceRange(position, position, slice);
26
- const startSlicePosition = tr.doc.resolve(Math.min(position + slice.content.size - slice.openEnd, tr.doc.content.size));
27
- const direction = -1;
28
- tr.setSelection(TextSelection.near(startSlicePosition, direction));
29
- }
30
- export function insertSliceIntoRangeSelectionInsideList({
31
- tr,
32
- slice
33
- }) {
34
- const {
35
- selection: {
36
- $to,
37
- $from,
38
- to,
39
- from
40
- }
41
- } = tr;
42
-
43
- // when the selection is inside of the same list item
44
- // we can use a normal replace
45
- if ($from.sameParent($to) || $from.depth === $to.depth) {
46
- return tr.replaceSelection(slice);
47
- }
48
-
49
- // if pasting a list inside another list, ensure no empty list items get added
50
- const newRange = $from.blockRange($to);
51
- if (!newRange) {
52
- return;
53
- }
54
- const startPos = from;
55
- const endPos = $to.nodeAfter ? to : to + 2;
56
- const newSlice = tr.doc.slice(endPos, newRange.end);
57
- tr.deleteRange(startPos, newRange.end);
58
- const mapped = tr.mapping.map(startPos);
59
- tr.replaceRange(mapped, mapped, slice);
60
- if (newSlice.size <= 0) {
61
- return;
62
- }
63
- const newSelection = TextSelection.near(tr.doc.resolve(tr.mapping.map(mapped)), -1);
64
- // @ts-ignore - [unblock prosemirror bump] assigning to readonly prop
65
- newSlice.openEnd = newSlice.openStart;
66
- tr.replaceRange(newSelection.from, newSelection.from, newSlice);
67
- tr.setSelection(TextSelection.near(tr.doc.resolve(newSelection.from), -1));
68
- }
69
- export function insertSliceInsideOfPanelNodeSelected(panelNode) {
70
- return ({
71
- tr,
72
- slice
73
- }) => {
74
- const {
75
- selection,
76
- selection: {
77
- $to,
78
- $from
79
- }
80
- } = tr;
81
- const {
82
- from: panelPosition
83
- } = selection;
84
-
85
- // if content of slice isn't valid for a panel node, insert the invalid node and following content after
86
- if (panelNode && !panelNode.type.validContent(Fragment.from(slice.content))) {
87
- var _parentNode$firstChil;
88
- const insertPosition = $to.pos + 1;
89
- tr.replaceRange(insertPosition, insertPosition, slice);
90
- // need to delete the empty paragraph at the top of the panel
91
- const parentNode = tr.doc.resolve($from.before()).node();
92
- if (parentNode && parentNode.childCount > 1 && ((_parentNode$firstChil = parentNode.firstChild) === null || _parentNode$firstChil === void 0 ? void 0 : _parentNode$firstChil.type.name) === 'paragraph' && isEmptyParagraph(parentNode.firstChild)) {
93
- const startPosDelete = tr.doc.resolve($from.before()).posAtIndex(0);
94
- const endPosDelete = tr.doc.resolve($from.before()).posAtIndex(1);
95
- const SIZE_OF_EMPTY_PARAGRAPH = 2; // {startPos}<p>{startPos + 1}</p>{endPos}
96
- if (endPosDelete - startPosDelete === SIZE_OF_EMPTY_PARAGRAPH) {
97
- tr.delete(startPosDelete, endPosDelete);
98
- }
99
- }
100
- tr.setSelection(TextSelection.near(tr.doc.resolve(insertPosition + slice.content.size - slice.openStart - slice.openEnd + 1)));
101
- return;
102
- }
103
- const temporaryDoc = new Transform(tr.doc.type.createAndFill());
104
- temporaryDoc.replaceRange(0, temporaryDoc.doc.content.size, slice);
105
- const sliceWithoutInvalidListSurrounding = temporaryDoc.doc.slice(0);
106
- const newPanel = panelNode.copy(sliceWithoutInvalidListSurrounding.content);
107
- const panelNodeSelected = selection instanceof NodeSelection ? selection.node : null;
108
- const replaceFrom = panelNodeSelected ? panelPosition : tr.doc.resolve(panelPosition).start();
109
- const replaceTo = panelNodeSelected ? panelPosition + panelNodeSelected.nodeSize : replaceFrom;
110
- tr.replaceRangeWith(replaceFrom, replaceTo, newPanel);
111
- tr.setSelection(TextSelection.near(tr.doc.resolve($from.pos + newPanel.content.size), -1));
112
- };
113
- }