@atlaskit/editor-plugin-block-controls 3.0.0 → 3.1.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 (34) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/dist/cjs/blockControlsPlugin.js +27 -14
  3. package/dist/cjs/editor-commands/move-node.js +15 -18
  4. package/dist/cjs/pm-plugins/decorations-common.js +2 -4
  5. package/dist/cjs/pm-plugins/main.js +73 -34
  6. package/dist/cjs/pm-plugins/utils/getSelection.js +1 -1
  7. package/dist/cjs/pm-plugins/utils/selection.js +34 -4
  8. package/dist/cjs/ui/consts.js +9 -1
  9. package/dist/cjs/ui/drag-handle.js +69 -36
  10. package/dist/es2019/blockControlsPlugin.js +27 -14
  11. package/dist/es2019/editor-commands/move-node.js +17 -20
  12. package/dist/es2019/pm-plugins/decorations-common.js +2 -4
  13. package/dist/es2019/pm-plugins/main.js +70 -23
  14. package/dist/es2019/pm-plugins/utils/getSelection.js +1 -1
  15. package/dist/es2019/pm-plugins/utils/selection.js +33 -3
  16. package/dist/es2019/ui/consts.js +8 -0
  17. package/dist/es2019/ui/drag-handle.js +59 -30
  18. package/dist/esm/blockControlsPlugin.js +27 -14
  19. package/dist/esm/editor-commands/move-node.js +16 -19
  20. package/dist/esm/pm-plugins/decorations-common.js +2 -4
  21. package/dist/esm/pm-plugins/main.js +71 -32
  22. package/dist/esm/pm-plugins/utils/getSelection.js +1 -1
  23. package/dist/esm/pm-plugins/utils/selection.js +33 -3
  24. package/dist/esm/ui/consts.js +8 -0
  25. package/dist/esm/ui/drag-handle.js +70 -37
  26. package/dist/types/blockControlsPluginType.d.ts +2 -0
  27. package/dist/types/pm-plugins/main.d.ts +2 -1
  28. package/dist/types/pm-plugins/utils/selection.d.ts +13 -1
  29. package/dist/types/ui/consts.d.ts +7 -0
  30. package/dist/types-ts4.5/blockControlsPluginType.d.ts +2 -0
  31. package/dist/types-ts4.5/pm-plugins/main.d.ts +2 -1
  32. package/dist/types-ts4.5/pm-plugins/utils/selection.d.ts +13 -1
  33. package/dist/types-ts4.5/ui/consts.d.ts +7 -0
  34. package/package.json +4 -4
@@ -1,5 +1,5 @@
1
1
  import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
2
- import { type Transaction } from '@atlaskit/editor-prosemirror/state';
2
+ import { type Transaction, type Selection } from '@atlaskit/editor-prosemirror/state';
3
3
  import type { BlockControlsPlugin } from '../../blockControlsPluginType';
4
4
  export declare const getMultiSelectionIfPosInside: (api: ExtractInjectionAPI<BlockControlsPlugin>, pos: number, tr?: Transaction) => {
5
5
  anchor?: number;
@@ -13,3 +13,15 @@ export declare const getSelectedSlicePosition: (handlePos: number, tr: Transacti
13
13
  from: number;
14
14
  to: number;
15
15
  };
16
+ /**
17
+ * Takes a position and expands the selection to encompass the node at that position. Ignores empty or out of range selections.
18
+ * Ignores positions that are in text blocks (i.e. not start of a node)
19
+ * @returns TextSelection if expanded, otherwise returns Selection that was passed in.
20
+ */
21
+ export declare const expandSelectionHeadToNodeAtPos: (selection: Selection, nodePos: number) => Selection;
22
+ /**
23
+ * This swaps the anchor/head for NodeSelections when its anchor > pos.
24
+ * This is because NodeSelection always has an anchor at the start of the node,
25
+ * which may not align with the existing selection.
26
+ */
27
+ export declare const alignAnchorHeadInDirectionOfPos: (selection: Selection, pos: number) => Selection;
@@ -15,6 +15,13 @@ export declare const DRAG_HANDLE_H5_TOP_ADJUSTMENT = 3;
15
15
  export declare const DRAG_HANDLE_H6_TOP_ADJUSTMENT = 3;
16
16
  export declare const DRAG_HANDLE_LAYOUT_SECTION_TOP_ADJUSTMENT = 8;
17
17
  export declare const DRAG_HANDLE_PARAGRAPH_TOP_ADJUSTMENT = 2;
18
+ /** We only want to shift-select nodes that are at the top level of a document.
19
+ * This is because funky things happen when selecting inside of tableCells, but we
20
+ * also want to avoid heavily nested cases to descope potential corner cases.
21
+ * Various top level nodes have their selection 'from' at depths other than 0,
22
+ * so we allow for some leniency to capture them all. e.g. Table is depth 3.
23
+ */
24
+ export declare const DRAG_HANDLE_MAX_SHIFT_CLICK_DEPTH = 3;
18
25
  export declare const dragHandleGap: (nodeType: string, parentNodeType?: string) => number;
19
26
  export declare const getNestedNodeLeftPaddingMargin: (nodeType?: string) => "8px" | "16px" | "20px" | "24px" | "28px" | "40px";
20
27
  export declare const topPositionAdjustment: (nodeType: string) => number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-block-controls",
3
- "version": "3.0.0",
3
+ "version": "3.1.0",
4
4
  "description": "Block controls plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -31,7 +31,7 @@
31
31
  },
32
32
  "dependencies": {
33
33
  "@atlaskit/adf-schema": "^47.2.1",
34
- "@atlaskit/editor-common": "^100.0.0",
34
+ "@atlaskit/editor-common": "^100.1.0",
35
35
  "@atlaskit/editor-plugin-accessibility-utils": "^2.0.0",
36
36
  "@atlaskit/editor-plugin-analytics": "^2.0.0",
37
37
  "@atlaskit/editor-plugin-editor-disabled": "^2.0.0",
@@ -49,8 +49,8 @@
49
49
  "@atlaskit/pragmatic-drag-and-drop-react-drop-indicator": "^2.0.0",
50
50
  "@atlaskit/primitives": "^14.0.0",
51
51
  "@atlaskit/theme": "^17.0.0",
52
- "@atlaskit/tmp-editor-statsig": "^3.0.0",
53
- "@atlaskit/tokens": "^4.0.0",
52
+ "@atlaskit/tmp-editor-statsig": "^3.2.0",
53
+ "@atlaskit/tokens": "^4.1.0",
54
54
  "@atlaskit/tooltip": "^20.0.0",
55
55
  "@babel/runtime": "^7.0.0",
56
56
  "@emotion/react": "^11.7.1",