@atlaskit/editor-plugin-paste-options-toolbar 9.1.4 → 9.1.5
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 +9 -0
- package/dist/cjs/ui/on-paste-actions-menu/PasteActionsMenu.js +18 -1
- package/dist/es2019/ui/on-paste-actions-menu/PasteActionsMenu.js +18 -2
- package/dist/esm/ui/on-paste-actions-menu/PasteActionsMenu.js +18 -2
- package/dist/types/ui/on-paste-actions-menu/PasteActionsMenu.d.ts +5 -0
- package/dist/types-ts4.5/ui/on-paste-actions-menu/PasteActionsMenu.d.ts +5 -0
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-paste-options-toolbar
|
|
2
2
|
|
|
3
|
+
## 9.1.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`2e030e319c013`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/2e030e319c013) -
|
|
8
|
+
[EDITOR-5982] Fix AI paste menu not appearing when pasting heading + text
|
|
9
|
+
- [`e7032ec0e9287`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/e7032ec0e9287) -
|
|
10
|
+
[ux] EDITOR-5983 Ensure paste menu is in correct position when first pasted node is empty
|
|
11
|
+
|
|
3
12
|
## 9.1.4
|
|
4
13
|
|
|
5
14
|
### Patch Changes
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
8
|
exports.PasteActionsMenu = void 0;
|
|
9
|
+
exports.getTargetElement = getTargetElement;
|
|
9
10
|
exports.getVisualEndBottom = getVisualEndBottom;
|
|
10
11
|
exports.onPositionCalculated = onPositionCalculated;
|
|
11
12
|
exports.resolveTableAfterPos = resolveTableAfterPos;
|
|
@@ -29,10 +30,21 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
29
30
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
30
31
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
31
32
|
var PopupWithListeners = (0, _uiReact.withReactEditorViewOuterListeners)(_ui.Popup);
|
|
33
|
+
/**
|
|
34
|
+
* Returns the DOM element at the given document position for use as a Popup anchor.
|
|
35
|
+
* For empty blocks (BR elements), returns the parent element to ensure correct positioning.
|
|
36
|
+
*/
|
|
32
37
|
function getTargetElement(editorView, pos) {
|
|
33
38
|
try {
|
|
34
39
|
var domRef = (0, _utils.findDomRefAtPos)(pos, editorView.domAtPos.bind(editorView));
|
|
35
40
|
if (domRef instanceof HTMLElement) {
|
|
41
|
+
// Empty blocks render a <br> placeholder whose bounding rect has no
|
|
42
|
+
// meaningful dimensions (height ≈ 0). Using it as the Popup anchor
|
|
43
|
+
// causes the menu to appear at an unexpected position. Walk up to the
|
|
44
|
+
// parent block element so the Popup anchors correctly.
|
|
45
|
+
if (domRef.nodeName === 'BR' && domRef.parentElement) {
|
|
46
|
+
return domRef.parentElement;
|
|
47
|
+
}
|
|
36
48
|
return domRef;
|
|
37
49
|
}
|
|
38
50
|
return null;
|
|
@@ -147,7 +159,12 @@ var PasteActionsMenu = exports.PasteActionsMenu = function PasteActionsMenu(_ref
|
|
|
147
159
|
var $pos = editorView.state.doc.resolve(lastContentPasted.pasteStartPos);
|
|
148
160
|
var pasteAncestorNodeNames = [];
|
|
149
161
|
for (var depth = $pos.depth; depth > 0; depth--) {
|
|
150
|
-
|
|
162
|
+
// Only include an ancestor if the entire pasted range is contained within it.
|
|
163
|
+
// This prevents nodes like 'heading' from being flagged as ancestors when the
|
|
164
|
+
// pasted content starts in a heading but extends beyond it (e.g. heading + paragraph).
|
|
165
|
+
if (lastContentPasted.pasteEndPos <= $pos.end(depth)) {
|
|
166
|
+
pasteAncestorNodeNames.push($pos.node(depth).type.name);
|
|
167
|
+
}
|
|
151
168
|
}
|
|
152
169
|
var legacyVisible = (0, _toolbar2.isToolbarVisible)(editorView.state, lastContentPasted) && ((_lastContentPasted$te = (_lastContentPasted$te2 = lastContentPasted.text) === null || _lastContentPasted$te2 === void 0 ? void 0 : _lastContentPasted$te2.length) !== null && _lastContentPasted$te !== void 0 ? _lastContentPasted$te : 0) >= 100;
|
|
153
170
|
(0, _commands.showToolbar)(lastContentPasted, selectedOption, legacyVisible, pasteAncestorNodeNames)(editorView.state, editorView.dispatch);
|
|
@@ -14,10 +14,21 @@ import { isToolbarVisible } from '../toolbar';
|
|
|
14
14
|
import { getVisibleKeys, hasVisibleButton } from './hasVisibleButton';
|
|
15
15
|
import { PasteActionsMenuContent } from './PasteActionsMenuContent';
|
|
16
16
|
const PopupWithListeners = withReactEditorViewOuterListeners(Popup);
|
|
17
|
-
|
|
17
|
+
/**
|
|
18
|
+
* Returns the DOM element at the given document position for use as a Popup anchor.
|
|
19
|
+
* For empty blocks (BR elements), returns the parent element to ensure correct positioning.
|
|
20
|
+
*/
|
|
21
|
+
export function getTargetElement(editorView, pos) {
|
|
18
22
|
try {
|
|
19
23
|
const domRef = findDomRefAtPos(pos, editorView.domAtPos.bind(editorView));
|
|
20
24
|
if (domRef instanceof HTMLElement) {
|
|
25
|
+
// Empty blocks render a <br> placeholder whose bounding rect has no
|
|
26
|
+
// meaningful dimensions (height ≈ 0). Using it as the Popup anchor
|
|
27
|
+
// causes the menu to appear at an unexpected position. Walk up to the
|
|
28
|
+
// parent block element so the Popup anchors correctly.
|
|
29
|
+
if (domRef.nodeName === 'BR' && domRef.parentElement) {
|
|
30
|
+
return domRef.parentElement;
|
|
31
|
+
}
|
|
21
32
|
return domRef;
|
|
22
33
|
}
|
|
23
34
|
return null;
|
|
@@ -135,7 +146,12 @@ export const PasteActionsMenu = ({
|
|
|
135
146
|
const $pos = editorView.state.doc.resolve(lastContentPasted.pasteStartPos);
|
|
136
147
|
const pasteAncestorNodeNames = [];
|
|
137
148
|
for (let depth = $pos.depth; depth > 0; depth--) {
|
|
138
|
-
|
|
149
|
+
// Only include an ancestor if the entire pasted range is contained within it.
|
|
150
|
+
// This prevents nodes like 'heading' from being flagged as ancestors when the
|
|
151
|
+
// pasted content starts in a heading but extends beyond it (e.g. heading + paragraph).
|
|
152
|
+
if (lastContentPasted.pasteEndPos <= $pos.end(depth)) {
|
|
153
|
+
pasteAncestorNodeNames.push($pos.node(depth).type.name);
|
|
154
|
+
}
|
|
139
155
|
}
|
|
140
156
|
const legacyVisible = isToolbarVisible(editorView.state, lastContentPasted) && ((_lastContentPasted$te = (_lastContentPasted$te2 = lastContentPasted.text) === null || _lastContentPasted$te2 === void 0 ? void 0 : _lastContentPasted$te2.length) !== null && _lastContentPasted$te !== void 0 ? _lastContentPasted$te : 0) >= 100;
|
|
141
157
|
showToolbar(lastContentPasted, selectedOption, legacyVisible, pasteAncestorNodeNames)(editorView.state, editorView.dispatch);
|
|
@@ -17,10 +17,21 @@ import { isToolbarVisible } from '../toolbar';
|
|
|
17
17
|
import { getVisibleKeys, hasVisibleButton } from './hasVisibleButton';
|
|
18
18
|
import { PasteActionsMenuContent } from './PasteActionsMenuContent';
|
|
19
19
|
var PopupWithListeners = withReactEditorViewOuterListeners(Popup);
|
|
20
|
-
|
|
20
|
+
/**
|
|
21
|
+
* Returns the DOM element at the given document position for use as a Popup anchor.
|
|
22
|
+
* For empty blocks (BR elements), returns the parent element to ensure correct positioning.
|
|
23
|
+
*/
|
|
24
|
+
export function getTargetElement(editorView, pos) {
|
|
21
25
|
try {
|
|
22
26
|
var domRef = findDomRefAtPos(pos, editorView.domAtPos.bind(editorView));
|
|
23
27
|
if (domRef instanceof HTMLElement) {
|
|
28
|
+
// Empty blocks render a <br> placeholder whose bounding rect has no
|
|
29
|
+
// meaningful dimensions (height ≈ 0). Using it as the Popup anchor
|
|
30
|
+
// causes the menu to appear at an unexpected position. Walk up to the
|
|
31
|
+
// parent block element so the Popup anchors correctly.
|
|
32
|
+
if (domRef.nodeName === 'BR' && domRef.parentElement) {
|
|
33
|
+
return domRef.parentElement;
|
|
34
|
+
}
|
|
24
35
|
return domRef;
|
|
25
36
|
}
|
|
26
37
|
return null;
|
|
@@ -135,7 +146,12 @@ export var PasteActionsMenu = function PasteActionsMenu(_ref) {
|
|
|
135
146
|
var $pos = editorView.state.doc.resolve(lastContentPasted.pasteStartPos);
|
|
136
147
|
var pasteAncestorNodeNames = [];
|
|
137
148
|
for (var depth = $pos.depth; depth > 0; depth--) {
|
|
138
|
-
|
|
149
|
+
// Only include an ancestor if the entire pasted range is contained within it.
|
|
150
|
+
// This prevents nodes like 'heading' from being flagged as ancestors when the
|
|
151
|
+
// pasted content starts in a heading but extends beyond it (e.g. heading + paragraph).
|
|
152
|
+
if (lastContentPasted.pasteEndPos <= $pos.end(depth)) {
|
|
153
|
+
pasteAncestorNodeNames.push($pos.node(depth).type.name);
|
|
154
|
+
}
|
|
139
155
|
}
|
|
140
156
|
var legacyVisible = isToolbarVisible(editorView.state, lastContentPasted) && ((_lastContentPasted$te = (_lastContentPasted$te2 = lastContentPasted.text) === null || _lastContentPasted$te2 === void 0 ? void 0 : _lastContentPasted$te2.length) !== null && _lastContentPasted$te !== void 0 ? _lastContentPasted$te : 0) >= 100;
|
|
141
157
|
showToolbar(lastContentPasted, selectedOption, legacyVisible, pasteAncestorNodeNames)(editorView.state, editorView.dispatch);
|
|
@@ -9,6 +9,11 @@ interface PasteActionsMenuProps {
|
|
|
9
9
|
mountTo?: HTMLElement;
|
|
10
10
|
scrollableElement?: HTMLElement;
|
|
11
11
|
}
|
|
12
|
+
/**
|
|
13
|
+
* Returns the DOM element at the given document position for use as a Popup anchor.
|
|
14
|
+
* For empty blocks (BR elements), returns the parent element to ensure correct positioning.
|
|
15
|
+
*/
|
|
16
|
+
export declare function getTargetElement(editorView: EditorView, pos: number): HTMLElement | null;
|
|
12
17
|
/**
|
|
13
18
|
* Returns the position immediately after a table ancestor of `pos`, or
|
|
14
19
|
* `undefined` if not inside a table. Safe to cache per document version.
|
|
@@ -9,6 +9,11 @@ interface PasteActionsMenuProps {
|
|
|
9
9
|
mountTo?: HTMLElement;
|
|
10
10
|
scrollableElement?: HTMLElement;
|
|
11
11
|
}
|
|
12
|
+
/**
|
|
13
|
+
* Returns the DOM element at the given document position for use as a Popup anchor.
|
|
14
|
+
* For empty blocks (BR elements), returns the parent element to ensure correct positioning.
|
|
15
|
+
*/
|
|
16
|
+
export declare function getTargetElement(editorView: EditorView, pos: number): HTMLElement | null;
|
|
12
17
|
/**
|
|
13
18
|
* Returns the position immediately after a table ancestor of `pos`, or
|
|
14
19
|
* `undefined` if not inside a table. Safe to cache per document version.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-paste-options-toolbar",
|
|
3
|
-
"version": "9.1.
|
|
3
|
+
"version": "9.1.5",
|
|
4
4
|
"description": "Paste options toolbar for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"react-intl-next": "npm:react-intl@^5.18.1"
|
|
49
49
|
},
|
|
50
50
|
"peerDependencies": {
|
|
51
|
-
"@atlaskit/editor-common": "^112.
|
|
51
|
+
"@atlaskit/editor-common": "^112.6.0",
|
|
52
52
|
"react": "^18.2.0",
|
|
53
53
|
"react-dom": "^18.2.0"
|
|
54
54
|
},
|