@atlaskit/editor-plugin-block-controls 12.1.1 → 12.2.1
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.
- package/CHANGELOG.md +21 -0
- package/dist/cjs/editor-commands/move-node.js +2 -1
- package/dist/cjs/pm-plugins/decorations-drag-handle.js +19 -1
- package/dist/cjs/pm-plugins/decorations-drop-target.js +2 -1
- package/dist/cjs/pm-plugins/decorations-quick-insert-button.js +19 -1
- package/dist/cjs/pm-plugins/main.js +77 -19
- package/dist/cjs/ui/consts.js +3 -1
- package/dist/cjs/ui/drag-handle.js +9 -0
- package/dist/cjs/ui/global-styles.js +13 -1
- package/dist/cjs/ui/quick-insert-button.js +8 -0
- package/dist/es2019/editor-commands/move-node.js +2 -1
- package/dist/es2019/pm-plugins/decorations-drag-handle.js +14 -0
- package/dist/es2019/pm-plugins/decorations-drop-target.js +2 -1
- package/dist/es2019/pm-plugins/decorations-quick-insert-button.js +13 -0
- package/dist/es2019/pm-plugins/main.js +79 -21
- package/dist/es2019/ui/consts.js +2 -0
- package/dist/es2019/ui/drag-handle.js +10 -1
- package/dist/es2019/ui/global-styles.js +17 -2
- package/dist/es2019/ui/quick-insert-button.js +9 -1
- package/dist/esm/editor-commands/move-node.js +2 -1
- package/dist/esm/pm-plugins/decorations-drag-handle.js +18 -0
- package/dist/esm/pm-plugins/decorations-drop-target.js +2 -1
- package/dist/esm/pm-plugins/decorations-quick-insert-button.js +18 -0
- package/dist/esm/pm-plugins/main.js +79 -21
- package/dist/esm/ui/consts.js +2 -0
- package/dist/esm/ui/drag-handle.js +10 -1
- package/dist/esm/ui/global-styles.js +14 -2
- package/dist/esm/ui/quick-insert-button.js +9 -1
- package/dist/types/pm-plugins/decorations-drag-handle.d.ts +7 -0
- package/dist/types/pm-plugins/decorations-quick-insert-button.d.ts +7 -0
- package/dist/types/ui/consts.d.ts +2 -0
- package/dist/types-ts4.5/pm-plugins/decorations-drag-handle.d.ts +7 -0
- package/dist/types-ts4.5/pm-plugins/decorations-quick-insert-button.d.ts +7 -0
- package/dist/types-ts4.5/ui/consts.d.ts +2 -0
- package/package.json +2 -2
|
@@ -12,7 +12,7 @@ import { ZERO_WIDTH_SPACE } from '@atlaskit/editor-common/whitespace';
|
|
|
12
12
|
import { akEditorBreakoutPadding, akEditorCalculatedWideLayoutWidth, akEditorCalculatedWideLayoutWidthSmallViewport, akEditorFullPageNarrowBreakout, akEditorGutterPaddingDynamic, akEditorGutterPaddingReduced } from '@atlaskit/editor-shared-styles';
|
|
13
13
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
14
14
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
15
|
-
import { DRAG_HANDLE_MAX_WIDTH_PLUS_GAP } from './consts';
|
|
15
|
+
import { ACTIVE_DRAG_HANDLE_ATTR, ACTIVE_QUICK_INSERT_ATTR, DRAG_HANDLE_MAX_WIDTH_PLUS_GAP } from './consts';
|
|
16
16
|
import { NODE_ANCHOR_ATTR_NAME } from './utils/dom-attr-name';
|
|
17
17
|
|
|
18
18
|
/**
|
|
@@ -356,6 +356,18 @@ var dragHandlerAnchorStyles = css({
|
|
|
356
356
|
})
|
|
357
357
|
}
|
|
358
358
|
});
|
|
359
|
+
var activeControlsSelector = "[".concat(ACTIVE_DRAG_HANDLE_ATTR, "], [").concat(ACTIVE_QUICK_INSERT_ATTR, "]");
|
|
360
|
+
|
|
361
|
+
// Applies anchor-name via node decoration attributes rather than adjacency CSS selectors.
|
|
362
|
+
// This is more reliable than dragHandlerAnchorStyles which depends on DOM structure.
|
|
363
|
+
// Only nodes decorated with data-active-drag-handle / data-active-quick-insert get anchor-name.
|
|
364
|
+
var staticControlsAnchorStyles = css({
|
|
365
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
|
|
366
|
+
'.ProseMirror': _defineProperty({}, activeControlsSelector, {
|
|
367
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values
|
|
368
|
+
anchorName: "var(".concat(ANCHOR_VARIABLE_NAME, ", attr(data-node-anchor type(<custom-ident>)))")
|
|
369
|
+
})
|
|
370
|
+
});
|
|
359
371
|
|
|
360
372
|
// Styles applied to nodes with anchors when dragging
|
|
361
373
|
var dragAnchorStyles = css({
|
|
@@ -404,6 +416,6 @@ export var GlobalStylesWrapper = function GlobalStylesWrapper(_ref) {
|
|
|
404
416
|
exposure: true
|
|
405
417
|
}) ? expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true) ? extendHoverZoneReducedNext : extendHoverZoneReduced : undefined,
|
|
406
418
|
// platform_editor_controls note: this allows drag handles to render on empty lines
|
|
407
|
-
toolbarFlagsEnabled ? undefined : withInlineNodeStyle, withDeleteLinesStyleFix, withMediaSingleStyleFix, legacyBreakoutWideLayoutStyle, headingWithIndentationInLayoutStyleFix, editorExperiment('advanced_layouts', true) ? blockCardWithoutLayout : undefined, withDividerInPanelStyleFix, withFormatInLayoutStyleFix, expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true) ? withRelativePosStyleNext : withRelativePosStyle, topLevelNodeMarginStyles, expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true) ? withAnchorNameZindexStyleNext : withAnchorNameZindexStyle, expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true) && expValEquals('advanced_layouts', 'isEnabled', true) ? layoutColumnExtendedHoverZone : layoutColumnWithoutHoverZone, shouldRenderAnchors && (isDragging ? dragAnchorStyles : dragHandlerAnchorStyles)]
|
|
419
|
+
toolbarFlagsEnabled ? undefined : withInlineNodeStyle, withDeleteLinesStyleFix, withMediaSingleStyleFix, legacyBreakoutWideLayoutStyle, headingWithIndentationInLayoutStyleFix, editorExperiment('advanced_layouts', true) ? blockCardWithoutLayout : undefined, withDividerInPanelStyleFix, withFormatInLayoutStyleFix, expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true) ? withRelativePosStyleNext : withRelativePosStyle, topLevelNodeMarginStyles, expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true) ? withAnchorNameZindexStyleNext : withAnchorNameZindexStyle, expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true) && expValEquals('advanced_layouts', 'isEnabled', true) ? layoutColumnExtendedHoverZone : layoutColumnWithoutHoverZone, shouldRenderAnchors && (isDragging ? dragAnchorStyles : dragHandlerAnchorStyles), expValEquals('platform_editor_controls_reliable_anchor', 'isEnabled', true) ? staticControlsAnchorStyles : undefined]
|
|
408
420
|
});
|
|
409
421
|
};
|
|
@@ -28,7 +28,7 @@ import Tooltip from '@atlaskit/tooltip';
|
|
|
28
28
|
import { getNodeTypeWithLevel } from '../pm-plugins/decorations-common';
|
|
29
29
|
import { getControlBottomCSSValue, getControlHeightCSSValue, getNodeHeight, getTopPosition, shouldBeSticky } from '../pm-plugins/utils/drag-handle-positions';
|
|
30
30
|
import { getLeftPositionForRootElement } from '../pm-plugins/utils/widget-positions';
|
|
31
|
-
import { QUICK_INSERT_DIMENSIONS, QUICK_INSERT_HEIGHT, QUICK_INSERT_LEFT_OFFSET, QUICK_INSERT_WIDTH, rootElementGap, STICKY_CONTROLS_TOP_MARGIN_FOR_STICKY_HEADER, topPositionAdjustment } from './consts';
|
|
31
|
+
import { ACTIVE_QUICK_INSERT_ATTR, QUICK_INSERT_DIMENSIONS, QUICK_INSERT_HEIGHT, QUICK_INSERT_LEFT_OFFSET, QUICK_INSERT_WIDTH, rootElementGap, STICKY_CONTROLS_TOP_MARGIN_FOR_STICKY_HEADER, topPositionAdjustment } from './consts';
|
|
32
32
|
import { refreshAnchorName } from './utils/anchor-name';
|
|
33
33
|
import { isInTextSelection, isNestedNodeSelected, isNonEditableBlock, isSelectionInNode } from './utils/document-checks';
|
|
34
34
|
import { getAnchorAttrName } from './utils/dom-attr-name';
|
|
@@ -184,6 +184,14 @@ export var TypeAheadControl = function TypeAheadControl(_ref) {
|
|
|
184
184
|
anchorName: rootAnchorName
|
|
185
185
|
});
|
|
186
186
|
var dom = view.dom.querySelector("[".concat(getAnchorAttrName(), "=\"").concat(safeAnchorName, "\"]"));
|
|
187
|
+
|
|
188
|
+
// Defence-in-depth guard: the node decoration sets data-active-quick-insert on the
|
|
189
|
+
// active root node. Check for it directly — cheap DOM attribute read, no reflow.
|
|
190
|
+
if (expValEquals('platform_editor_controls_reliable_anchor', 'isEnabled', true) && !(dom !== null && dom !== void 0 && dom.hasAttribute(ACTIVE_QUICK_INSERT_ATTR))) {
|
|
191
|
+
return {
|
|
192
|
+
display: 'none'
|
|
193
|
+
};
|
|
194
|
+
}
|
|
187
195
|
var hasResizer = rootNodeType === 'table' || rootNodeType === 'mediaSingle';
|
|
188
196
|
var isExtension = rootNodeType === 'extension' || rootNodeType === 'bodiedExtension' || rootNodeType === 'multiBodiedExtension' && fg('confluence_frontend_native_tabs_extension');
|
|
189
197
|
var isBlockCard = rootNodeType === 'blockCard';
|
|
@@ -6,6 +6,13 @@ import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
|
6
6
|
import type { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
7
7
|
import type { BlockControlsPlugin, HandleOptions } from '../blockControlsPluginType';
|
|
8
8
|
import type { AnchorRectCache } from './utils/anchor-utils';
|
|
9
|
+
/**
|
|
10
|
+
* Creates a Decoration.node that marks the active node with `data-active-drag-handle="true"`.
|
|
11
|
+
* The CSS in staticControlsAnchorStyles then applies `anchor-name` to this attribute,
|
|
12
|
+
* which is more reliable than the adjacency-selector approach in dragHandlerAnchorStyles.
|
|
13
|
+
*/
|
|
14
|
+
export declare const createActiveDragHandleNodeDecoration: (pos: number, nodeSize: number) => Decoration;
|
|
15
|
+
export declare const findActiveDragHandleNodeDec: (decorations: DecorationSet, from?: number, to?: number) => Decoration[];
|
|
9
16
|
export declare const emptyParagraphNodeDecorations: () => Decoration;
|
|
10
17
|
export declare const findHandleDec: (decorations: DecorationSet, from?: number, to?: number) => Decoration[];
|
|
11
18
|
type DragHandleDecorationParams = {
|
|
@@ -19,5 +19,12 @@ type QuickInsertButtonDecorationParams = {
|
|
|
19
19
|
rootNodeType?: string;
|
|
20
20
|
rootPos: number;
|
|
21
21
|
};
|
|
22
|
+
/**
|
|
23
|
+
* Creates a Decoration.node that marks the active node with `data-active-quick-insert="true"`.
|
|
24
|
+
* The CSS in staticControlsAnchorStyles applies `anchor-name` to this attribute directly,
|
|
25
|
+
* replacing the unreliable adjacency selector `[block-ctrl-quick-insert-button] + *`.
|
|
26
|
+
*/
|
|
27
|
+
export declare const createActiveQuickInsertNodeDecoration: (pos: number, nodeSize: number) => Decoration;
|
|
28
|
+
export declare const findActiveQuickInsertNodeDec: (decorations: DecorationSet, from?: number, to?: number) => Decoration[];
|
|
22
29
|
export declare const quickInsertButtonDecoration: ({ api, formatMessage, rootPos, anchorName, nodeType, nodeViewPortalProviderAPI, rootAnchorName, rootNodeType, anchorRectCache, editorState, }: QuickInsertButtonDecorationParams) => Decoration;
|
|
23
30
|
export {};
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
export declare const ACTIVE_DRAG_HANDLE_ATTR = "data-active-drag-handle";
|
|
2
|
+
export declare const ACTIVE_QUICK_INSERT_ATTR = "data-active-quick-insert";
|
|
1
3
|
export declare const DRAG_HANDLE_HEIGHT = 24;
|
|
2
4
|
export declare const DRAG_HANDLE_BORDER_RADIUS = 4;
|
|
3
5
|
export declare const DRAG_HANDLE_ZINDEX: number;
|
|
@@ -6,6 +6,13 @@ import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
|
6
6
|
import type { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
7
7
|
import type { BlockControlsPlugin, HandleOptions } from '../blockControlsPluginType';
|
|
8
8
|
import type { AnchorRectCache } from './utils/anchor-utils';
|
|
9
|
+
/**
|
|
10
|
+
* Creates a Decoration.node that marks the active node with `data-active-drag-handle="true"`.
|
|
11
|
+
* The CSS in staticControlsAnchorStyles then applies `anchor-name` to this attribute,
|
|
12
|
+
* which is more reliable than the adjacency-selector approach in dragHandlerAnchorStyles.
|
|
13
|
+
*/
|
|
14
|
+
export declare const createActiveDragHandleNodeDecoration: (pos: number, nodeSize: number) => Decoration;
|
|
15
|
+
export declare const findActiveDragHandleNodeDec: (decorations: DecorationSet, from?: number, to?: number) => Decoration[];
|
|
9
16
|
export declare const emptyParagraphNodeDecorations: () => Decoration;
|
|
10
17
|
export declare const findHandleDec: (decorations: DecorationSet, from?: number, to?: number) => Decoration[];
|
|
11
18
|
type DragHandleDecorationParams = {
|
|
@@ -19,5 +19,12 @@ type QuickInsertButtonDecorationParams = {
|
|
|
19
19
|
rootNodeType?: string;
|
|
20
20
|
rootPos: number;
|
|
21
21
|
};
|
|
22
|
+
/**
|
|
23
|
+
* Creates a Decoration.node that marks the active node with `data-active-quick-insert="true"`.
|
|
24
|
+
* The CSS in staticControlsAnchorStyles applies `anchor-name` to this attribute directly,
|
|
25
|
+
* replacing the unreliable adjacency selector `[block-ctrl-quick-insert-button] + *`.
|
|
26
|
+
*/
|
|
27
|
+
export declare const createActiveQuickInsertNodeDecoration: (pos: number, nodeSize: number) => Decoration;
|
|
28
|
+
export declare const findActiveQuickInsertNodeDec: (decorations: DecorationSet, from?: number, to?: number) => Decoration[];
|
|
22
29
|
export declare const quickInsertButtonDecoration: ({ api, formatMessage, rootPos, anchorName, nodeType, nodeViewPortalProviderAPI, rootAnchorName, rootNodeType, anchorRectCache, editorState, }: QuickInsertButtonDecorationParams) => Decoration;
|
|
23
30
|
export {};
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
export declare const ACTIVE_DRAG_HANDLE_ATTR = "data-active-drag-handle";
|
|
2
|
+
export declare const ACTIVE_QUICK_INSERT_ATTR = "data-active-quick-insert";
|
|
1
3
|
export declare const DRAG_HANDLE_HEIGHT = 24;
|
|
2
4
|
export declare const DRAG_HANDLE_BORDER_RADIUS = 4;
|
|
3
5
|
export declare const DRAG_HANDLE_ZINDEX: number;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-block-controls",
|
|
3
|
-
"version": "12.
|
|
3
|
+
"version": "12.2.1",
|
|
4
4
|
"description": "Block controls plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"@atlaskit/pragmatic-drag-and-drop-react-drop-indicator": "^3.2.0",
|
|
57
57
|
"@atlaskit/primitives": "^19.0.0",
|
|
58
58
|
"@atlaskit/theme": "^25.0.0",
|
|
59
|
-
"@atlaskit/tmp-editor-statsig": "^90.
|
|
59
|
+
"@atlaskit/tmp-editor-statsig": "^90.2.0",
|
|
60
60
|
"@atlaskit/tokens": "^13.3.0",
|
|
61
61
|
"@atlaskit/tooltip": "^22.6.0",
|
|
62
62
|
"@babel/runtime": "^7.0.0",
|