@tiptap/vue-2 3.0.0 → 3.0.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/LICENSE.md +21 -0
- package/README.md +5 -1
- package/dist/index.cjs +340 -349
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +79 -0
- package/dist/index.d.ts +79 -0
- package/dist/index.js +298 -337
- package/dist/index.js.map +1 -1
- package/dist/menus/index.cjs +2273 -0
- package/dist/menus/index.cjs.map +1 -0
- package/dist/menus/index.d.cts +139 -0
- package/dist/menus/index.d.ts +139 -0
- package/dist/menus/index.js +2245 -0
- package/dist/menus/index.js.map +1 -0
- package/package.json +28 -16
- package/src/Editor.ts +1 -1
- package/src/EditorContent.ts +7 -5
- package/src/NodeViewContent.ts +3 -2
- package/src/NodeViewWrapper.ts +6 -5
- package/src/VueNodeViewRenderer.ts +80 -27
- package/src/VueRenderer.ts +5 -7
- package/src/index.ts +0 -2
- package/src/menus/BubbleMenu.ts +85 -0
- package/src/{FloatingMenu.ts → menus/FloatingMenu.ts} +24 -15
- package/src/menus/index.ts +2 -0
- package/dist/index.umd.js +0 -379
- package/dist/index.umd.js.map +0 -1
- package/dist/packages/core/src/CommandManager.d.ts +0 -20
- package/dist/packages/core/src/Editor.d.ts +0 -161
- package/dist/packages/core/src/EventEmitter.d.ts +0 -11
- package/dist/packages/core/src/Extension.d.ts +0 -343
- package/dist/packages/core/src/ExtensionManager.d.ts +0 -55
- package/dist/packages/core/src/InputRule.d.ts +0 -42
- package/dist/packages/core/src/Mark.d.ts +0 -451
- package/dist/packages/core/src/Node.d.ts +0 -611
- package/dist/packages/core/src/NodePos.d.ts +0 -44
- package/dist/packages/core/src/NodeView.d.ts +0 -31
- package/dist/packages/core/src/PasteRule.d.ts +0 -50
- package/dist/packages/core/src/Tracker.d.ts +0 -11
- package/dist/packages/core/src/commands/blur.d.ts +0 -13
- package/dist/packages/core/src/commands/clearContent.d.ts +0 -14
- package/dist/packages/core/src/commands/clearNodes.d.ts +0 -13
- package/dist/packages/core/src/commands/command.d.ts +0 -18
- package/dist/packages/core/src/commands/createParagraphNear.d.ts +0 -13
- package/dist/packages/core/src/commands/cut.d.ts +0 -20
- package/dist/packages/core/src/commands/deleteCurrentNode.d.ts +0 -13
- package/dist/packages/core/src/commands/deleteNode.d.ts +0 -15
- package/dist/packages/core/src/commands/deleteRange.d.ts +0 -14
- package/dist/packages/core/src/commands/deleteSelection.d.ts +0 -13
- package/dist/packages/core/src/commands/enter.d.ts +0 -13
- package/dist/packages/core/src/commands/exitCode.d.ts +0 -13
- package/dist/packages/core/src/commands/extendMarkRange.d.ts +0 -25
- package/dist/packages/core/src/commands/first.d.ts +0 -14
- package/dist/packages/core/src/commands/focus.d.ts +0 -27
- package/dist/packages/core/src/commands/forEach.d.ts +0 -14
- package/dist/packages/core/src/commands/index.d.ts +0 -55
- package/dist/packages/core/src/commands/insertContent.d.ts +0 -34
- package/dist/packages/core/src/commands/insertContentAt.d.ts +0 -47
- package/dist/packages/core/src/commands/join.d.ts +0 -41
- package/dist/packages/core/src/commands/joinItemBackward.d.ts +0 -13
- package/dist/packages/core/src/commands/joinItemForward.d.ts +0 -13
- package/dist/packages/core/src/commands/joinTextblockBackward.d.ts +0 -12
- package/dist/packages/core/src/commands/joinTextblockForward.d.ts +0 -12
- package/dist/packages/core/src/commands/keyboardShortcut.d.ts +0 -14
- package/dist/packages/core/src/commands/lift.d.ts +0 -17
- package/dist/packages/core/src/commands/liftEmptyBlock.d.ts +0 -13
- package/dist/packages/core/src/commands/liftListItem.d.ts +0 -15
- package/dist/packages/core/src/commands/newlineInCode.d.ts +0 -13
- package/dist/packages/core/src/commands/resetAttributes.d.ts +0 -16
- package/dist/packages/core/src/commands/scrollIntoView.d.ts +0 -13
- package/dist/packages/core/src/commands/selectAll.d.ts +0 -13
- package/dist/packages/core/src/commands/selectNodeBackward.d.ts +0 -13
- package/dist/packages/core/src/commands/selectNodeForward.d.ts +0 -13
- package/dist/packages/core/src/commands/selectParentNode.d.ts +0 -13
- package/dist/packages/core/src/commands/selectTextblockEnd.d.ts +0 -13
- package/dist/packages/core/src/commands/selectTextblockStart.d.ts +0 -13
- package/dist/packages/core/src/commands/setContent.d.ts +0 -40
- package/dist/packages/core/src/commands/setMark.d.ts +0 -15
- package/dist/packages/core/src/commands/setMeta.d.ts +0 -15
- package/dist/packages/core/src/commands/setNode.d.ts +0 -16
- package/dist/packages/core/src/commands/setNodeSelection.d.ts +0 -14
- package/dist/packages/core/src/commands/setTextSelection.d.ts +0 -14
- package/dist/packages/core/src/commands/sinkListItem.d.ts +0 -15
- package/dist/packages/core/src/commands/splitBlock.d.ts +0 -17
- package/dist/packages/core/src/commands/splitListItem.d.ts +0 -15
- package/dist/packages/core/src/commands/toggleList.d.ts +0 -18
- package/dist/packages/core/src/commands/toggleMark.d.ts +0 -30
- package/dist/packages/core/src/commands/toggleNode.d.ts +0 -17
- package/dist/packages/core/src/commands/toggleWrap.d.ts +0 -16
- package/dist/packages/core/src/commands/undoInputRule.d.ts +0 -13
- package/dist/packages/core/src/commands/unsetAllMarks.d.ts +0 -13
- package/dist/packages/core/src/commands/unsetMark.d.ts +0 -25
- package/dist/packages/core/src/commands/updateAttributes.d.ts +0 -24
- package/dist/packages/core/src/commands/wrapIn.d.ts +0 -16
- package/dist/packages/core/src/commands/wrapInList.d.ts +0 -16
- package/dist/packages/core/src/extensions/clipboardTextSerializer.d.ts +0 -5
- package/dist/packages/core/src/extensions/commands.d.ts +0 -3
- package/dist/packages/core/src/extensions/editable.d.ts +0 -2
- package/dist/packages/core/src/extensions/focusEvents.d.ts +0 -2
- package/dist/packages/core/src/extensions/index.d.ts +0 -6
- package/dist/packages/core/src/extensions/keymap.d.ts +0 -2
- package/dist/packages/core/src/extensions/tabindex.d.ts +0 -2
- package/dist/packages/core/src/helpers/combineTransactionSteps.d.ts +0 -10
- package/dist/packages/core/src/helpers/createChainableState.d.ts +0 -10
- package/dist/packages/core/src/helpers/createDocument.d.ts +0 -12
- package/dist/packages/core/src/helpers/createNodeFromContent.d.ts +0 -15
- package/dist/packages/core/src/helpers/defaultBlockAt.d.ts +0 -7
- package/dist/packages/core/src/helpers/findChildren.d.ts +0 -9
- package/dist/packages/core/src/helpers/findChildrenInRange.d.ts +0 -10
- package/dist/packages/core/src/helpers/findParentNode.d.ts +0 -16
- package/dist/packages/core/src/helpers/findParentNodeClosestToPos.d.ts +0 -17
- package/dist/packages/core/src/helpers/generateHTML.d.ts +0 -8
- package/dist/packages/core/src/helpers/generateJSON.d.ts +0 -8
- package/dist/packages/core/src/helpers/generateText.d.ts +0 -12
- package/dist/packages/core/src/helpers/getAttributes.d.ts +0 -9
- package/dist/packages/core/src/helpers/getAttributesFromExtensions.d.ts +0 -6
- package/dist/packages/core/src/helpers/getChangedRanges.d.ts +0 -11
- package/dist/packages/core/src/helpers/getDebugJSON.d.ts +0 -8
- package/dist/packages/core/src/helpers/getExtensionField.d.ts +0 -9
- package/dist/packages/core/src/helpers/getHTMLFromFragment.d.ts +0 -2
- package/dist/packages/core/src/helpers/getMarkAttributes.d.ts +0 -3
- package/dist/packages/core/src/helpers/getMarkRange.d.ts +0 -3
- package/dist/packages/core/src/helpers/getMarkType.d.ts +0 -2
- package/dist/packages/core/src/helpers/getMarksBetween.d.ts +0 -3
- package/dist/packages/core/src/helpers/getNodeAtPosition.d.ts +0 -11
- package/dist/packages/core/src/helpers/getNodeAttributes.d.ts +0 -3
- package/dist/packages/core/src/helpers/getNodeType.d.ts +0 -2
- package/dist/packages/core/src/helpers/getRenderedAttributes.d.ts +0 -3
- package/dist/packages/core/src/helpers/getSchema.d.ts +0 -4
- package/dist/packages/core/src/helpers/getSchemaByResolvedExtensions.d.ts +0 -10
- package/dist/packages/core/src/helpers/getSchemaTypeByName.d.ts +0 -8
- package/dist/packages/core/src/helpers/getSchemaTypeNameByName.d.ts +0 -8
- package/dist/packages/core/src/helpers/getSplittedAttributes.d.ts +0 -9
- package/dist/packages/core/src/helpers/getText.d.ts +0 -15
- package/dist/packages/core/src/helpers/getTextBetween.d.ts +0 -14
- package/dist/packages/core/src/helpers/getTextContentFromNodes.d.ts +0 -8
- package/dist/packages/core/src/helpers/getTextSerializersFromSchema.d.ts +0 -8
- package/dist/packages/core/src/helpers/index.d.ts +0 -50
- package/dist/packages/core/src/helpers/injectExtensionAttributesToParseRule.d.ts +0 -9
- package/dist/packages/core/src/helpers/isActive.d.ts +0 -2
- package/dist/packages/core/src/helpers/isAtEndOfNode.d.ts +0 -2
- package/dist/packages/core/src/helpers/isAtStartOfNode.d.ts +0 -2
- package/dist/packages/core/src/helpers/isExtensionRulesEnabled.d.ts +0 -2
- package/dist/packages/core/src/helpers/isList.d.ts +0 -2
- package/dist/packages/core/src/helpers/isMarkActive.d.ts +0 -3
- package/dist/packages/core/src/helpers/isNodeActive.d.ts +0 -3
- package/dist/packages/core/src/helpers/isNodeEmpty.d.ts +0 -2
- package/dist/packages/core/src/helpers/isNodeSelection.d.ts +0 -2
- package/dist/packages/core/src/helpers/isTextSelection.d.ts +0 -2
- package/dist/packages/core/src/helpers/posToDOMRect.d.ts +0 -2
- package/dist/packages/core/src/helpers/resolveFocusPosition.d.ts +0 -4
- package/dist/packages/core/src/helpers/selectionToInsertionEnd.d.ts +0 -2
- package/dist/packages/core/src/helpers/splitExtensions.d.ts +0 -9
- package/dist/packages/core/src/index.d.ts +0 -24
- package/dist/packages/core/src/inputRules/index.d.ts +0 -5
- package/dist/packages/core/src/inputRules/markInputRule.d.ts +0 -13
- package/dist/packages/core/src/inputRules/nodeInputRule.d.ts +0 -23
- package/dist/packages/core/src/inputRules/textInputRule.d.ts +0 -10
- package/dist/packages/core/src/inputRules/textblockTypeInputRule.d.ts +0 -15
- package/dist/packages/core/src/inputRules/wrappingInputRule.d.ts +0 -28
- package/dist/packages/core/src/pasteRules/index.d.ts +0 -3
- package/dist/packages/core/src/pasteRules/markPasteRule.d.ts +0 -13
- package/dist/packages/core/src/pasteRules/nodePasteRule.d.ts +0 -13
- package/dist/packages/core/src/pasteRules/textPasteRule.d.ts +0 -10
- package/dist/packages/core/src/style.d.ts +0 -1
- package/dist/packages/core/src/types.d.ts +0 -255
- package/dist/packages/core/src/utilities/callOrReturn.d.ts +0 -9
- package/dist/packages/core/src/utilities/createStyleTag.d.ts +0 -1
- package/dist/packages/core/src/utilities/deleteProps.d.ts +0 -6
- package/dist/packages/core/src/utilities/elementFromString.d.ts +0 -1
- package/dist/packages/core/src/utilities/escapeForRegEx.d.ts +0 -1
- package/dist/packages/core/src/utilities/findDuplicates.d.ts +0 -1
- package/dist/packages/core/src/utilities/fromString.d.ts +0 -1
- package/dist/packages/core/src/utilities/index.d.ts +0 -20
- package/dist/packages/core/src/utilities/isAndroid.d.ts +0 -1
- package/dist/packages/core/src/utilities/isEmptyObject.d.ts +0 -1
- package/dist/packages/core/src/utilities/isFunction.d.ts +0 -1
- package/dist/packages/core/src/utilities/isMacOS.d.ts +0 -1
- package/dist/packages/core/src/utilities/isNumber.d.ts +0 -1
- package/dist/packages/core/src/utilities/isPlainObject.d.ts +0 -1
- package/dist/packages/core/src/utilities/isRegExp.d.ts +0 -1
- package/dist/packages/core/src/utilities/isString.d.ts +0 -1
- package/dist/packages/core/src/utilities/isiOS.d.ts +0 -1
- package/dist/packages/core/src/utilities/mergeAttributes.d.ts +0 -1
- package/dist/packages/core/src/utilities/mergeDeep.d.ts +0 -1
- package/dist/packages/core/src/utilities/minMax.d.ts +0 -1
- package/dist/packages/core/src/utilities/objectIncludes.d.ts +0 -8
- package/dist/packages/core/src/utilities/removeDuplicates.d.ts +0 -8
- package/dist/packages/extension-bubble-menu/src/bubble-menu-plugin.d.ts +0 -76
- package/dist/packages/extension-bubble-menu/src/bubble-menu.d.ts +0 -15
- package/dist/packages/extension-bubble-menu/src/index.d.ts +0 -4
- package/dist/packages/extension-floating-menu/src/floating-menu-plugin.d.ts +0 -66
- package/dist/packages/extension-floating-menu/src/floating-menu.d.ts +0 -15
- package/dist/packages/extension-floating-menu/src/index.d.ts +0 -4
- package/dist/packages/vue-2/src/BubbleMenu.d.ts +0 -10
- package/dist/packages/vue-2/src/Editor.d.ts +0 -5
- package/dist/packages/vue-2/src/EditorContent.d.ts +0 -6
- package/dist/packages/vue-2/src/FloatingMenu.d.ts +0 -9
- package/dist/packages/vue-2/src/NodeViewContent.d.ts +0 -5
- package/dist/packages/vue-2/src/NodeViewWrapper.d.ts +0 -9
- package/dist/packages/vue-2/src/VueNodeViewRenderer.d.ts +0 -37
- package/dist/packages/vue-2/src/VueRenderer.d.ts +0 -12
- package/dist/packages/vue-2/src/index.d.ts +0 -9
- package/src/BubbleMenu.ts +0 -70
|
@@ -0,0 +1,2245 @@
|
|
|
1
|
+
// ../extension-bubble-menu/dist/index.js
|
|
2
|
+
import { Extension } from "@tiptap/core";
|
|
3
|
+
|
|
4
|
+
// ../../node_modules/.pnpm/@floating-ui+utils@0.2.9/node_modules/@floating-ui/utils/dist/floating-ui.utils.mjs
|
|
5
|
+
var sides = ["top", "right", "bottom", "left"];
|
|
6
|
+
var alignments = ["start", "end"];
|
|
7
|
+
var placements = /* @__PURE__ */ sides.reduce((acc, side) => acc.concat(side, side + "-" + alignments[0], side + "-" + alignments[1]), []);
|
|
8
|
+
var min = Math.min;
|
|
9
|
+
var max = Math.max;
|
|
10
|
+
var round = Math.round;
|
|
11
|
+
var createCoords = (v) => ({
|
|
12
|
+
x: v,
|
|
13
|
+
y: v
|
|
14
|
+
});
|
|
15
|
+
var oppositeSideMap = {
|
|
16
|
+
left: "right",
|
|
17
|
+
right: "left",
|
|
18
|
+
bottom: "top",
|
|
19
|
+
top: "bottom"
|
|
20
|
+
};
|
|
21
|
+
var oppositeAlignmentMap = {
|
|
22
|
+
start: "end",
|
|
23
|
+
end: "start"
|
|
24
|
+
};
|
|
25
|
+
function clamp(start, value, end) {
|
|
26
|
+
return max(start, min(value, end));
|
|
27
|
+
}
|
|
28
|
+
function evaluate(value, param) {
|
|
29
|
+
return typeof value === "function" ? value(param) : value;
|
|
30
|
+
}
|
|
31
|
+
function getSide(placement) {
|
|
32
|
+
return placement.split("-")[0];
|
|
33
|
+
}
|
|
34
|
+
function getAlignment(placement) {
|
|
35
|
+
return placement.split("-")[1];
|
|
36
|
+
}
|
|
37
|
+
function getOppositeAxis(axis) {
|
|
38
|
+
return axis === "x" ? "y" : "x";
|
|
39
|
+
}
|
|
40
|
+
function getAxisLength(axis) {
|
|
41
|
+
return axis === "y" ? "height" : "width";
|
|
42
|
+
}
|
|
43
|
+
function getSideAxis(placement) {
|
|
44
|
+
return ["top", "bottom"].includes(getSide(placement)) ? "y" : "x";
|
|
45
|
+
}
|
|
46
|
+
function getAlignmentAxis(placement) {
|
|
47
|
+
return getOppositeAxis(getSideAxis(placement));
|
|
48
|
+
}
|
|
49
|
+
function getAlignmentSides(placement, rects, rtl) {
|
|
50
|
+
if (rtl === void 0) {
|
|
51
|
+
rtl = false;
|
|
52
|
+
}
|
|
53
|
+
const alignment = getAlignment(placement);
|
|
54
|
+
const alignmentAxis = getAlignmentAxis(placement);
|
|
55
|
+
const length = getAxisLength(alignmentAxis);
|
|
56
|
+
let mainAlignmentSide = alignmentAxis === "x" ? alignment === (rtl ? "end" : "start") ? "right" : "left" : alignment === "start" ? "bottom" : "top";
|
|
57
|
+
if (rects.reference[length] > rects.floating[length]) {
|
|
58
|
+
mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
|
|
59
|
+
}
|
|
60
|
+
return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)];
|
|
61
|
+
}
|
|
62
|
+
function getExpandedPlacements(placement) {
|
|
63
|
+
const oppositePlacement = getOppositePlacement(placement);
|
|
64
|
+
return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
|
|
65
|
+
}
|
|
66
|
+
function getOppositeAlignmentPlacement(placement) {
|
|
67
|
+
return placement.replace(/start|end/g, (alignment) => oppositeAlignmentMap[alignment]);
|
|
68
|
+
}
|
|
69
|
+
function getSideList(side, isStart, rtl) {
|
|
70
|
+
const lr = ["left", "right"];
|
|
71
|
+
const rl = ["right", "left"];
|
|
72
|
+
const tb = ["top", "bottom"];
|
|
73
|
+
const bt = ["bottom", "top"];
|
|
74
|
+
switch (side) {
|
|
75
|
+
case "top":
|
|
76
|
+
case "bottom":
|
|
77
|
+
if (rtl) return isStart ? rl : lr;
|
|
78
|
+
return isStart ? lr : rl;
|
|
79
|
+
case "left":
|
|
80
|
+
case "right":
|
|
81
|
+
return isStart ? tb : bt;
|
|
82
|
+
default:
|
|
83
|
+
return [];
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
|
|
87
|
+
const alignment = getAlignment(placement);
|
|
88
|
+
let list = getSideList(getSide(placement), direction === "start", rtl);
|
|
89
|
+
if (alignment) {
|
|
90
|
+
list = list.map((side) => side + "-" + alignment);
|
|
91
|
+
if (flipAlignment) {
|
|
92
|
+
list = list.concat(list.map(getOppositeAlignmentPlacement));
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return list;
|
|
96
|
+
}
|
|
97
|
+
function getOppositePlacement(placement) {
|
|
98
|
+
return placement.replace(/left|right|bottom|top/g, (side) => oppositeSideMap[side]);
|
|
99
|
+
}
|
|
100
|
+
function expandPaddingObject(padding) {
|
|
101
|
+
return {
|
|
102
|
+
top: 0,
|
|
103
|
+
right: 0,
|
|
104
|
+
bottom: 0,
|
|
105
|
+
left: 0,
|
|
106
|
+
...padding
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
function getPaddingObject(padding) {
|
|
110
|
+
return typeof padding !== "number" ? expandPaddingObject(padding) : {
|
|
111
|
+
top: padding,
|
|
112
|
+
right: padding,
|
|
113
|
+
bottom: padding,
|
|
114
|
+
left: padding
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
function rectToClientRect(rect) {
|
|
118
|
+
const {
|
|
119
|
+
x,
|
|
120
|
+
y,
|
|
121
|
+
width,
|
|
122
|
+
height
|
|
123
|
+
} = rect;
|
|
124
|
+
return {
|
|
125
|
+
width,
|
|
126
|
+
height,
|
|
127
|
+
top: y,
|
|
128
|
+
left: x,
|
|
129
|
+
right: x + width,
|
|
130
|
+
bottom: y + height,
|
|
131
|
+
x,
|
|
132
|
+
y
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// ../../node_modules/.pnpm/@floating-ui+core@1.6.9/node_modules/@floating-ui/core/dist/floating-ui.core.mjs
|
|
137
|
+
function computeCoordsFromPlacement(_ref, placement, rtl) {
|
|
138
|
+
let {
|
|
139
|
+
reference,
|
|
140
|
+
floating
|
|
141
|
+
} = _ref;
|
|
142
|
+
const sideAxis = getSideAxis(placement);
|
|
143
|
+
const alignmentAxis = getAlignmentAxis(placement);
|
|
144
|
+
const alignLength = getAxisLength(alignmentAxis);
|
|
145
|
+
const side = getSide(placement);
|
|
146
|
+
const isVertical = sideAxis === "y";
|
|
147
|
+
const commonX = reference.x + reference.width / 2 - floating.width / 2;
|
|
148
|
+
const commonY = reference.y + reference.height / 2 - floating.height / 2;
|
|
149
|
+
const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2;
|
|
150
|
+
let coords;
|
|
151
|
+
switch (side) {
|
|
152
|
+
case "top":
|
|
153
|
+
coords = {
|
|
154
|
+
x: commonX,
|
|
155
|
+
y: reference.y - floating.height
|
|
156
|
+
};
|
|
157
|
+
break;
|
|
158
|
+
case "bottom":
|
|
159
|
+
coords = {
|
|
160
|
+
x: commonX,
|
|
161
|
+
y: reference.y + reference.height
|
|
162
|
+
};
|
|
163
|
+
break;
|
|
164
|
+
case "right":
|
|
165
|
+
coords = {
|
|
166
|
+
x: reference.x + reference.width,
|
|
167
|
+
y: commonY
|
|
168
|
+
};
|
|
169
|
+
break;
|
|
170
|
+
case "left":
|
|
171
|
+
coords = {
|
|
172
|
+
x: reference.x - floating.width,
|
|
173
|
+
y: commonY
|
|
174
|
+
};
|
|
175
|
+
break;
|
|
176
|
+
default:
|
|
177
|
+
coords = {
|
|
178
|
+
x: reference.x,
|
|
179
|
+
y: reference.y
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
switch (getAlignment(placement)) {
|
|
183
|
+
case "start":
|
|
184
|
+
coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
|
|
185
|
+
break;
|
|
186
|
+
case "end":
|
|
187
|
+
coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
|
|
188
|
+
break;
|
|
189
|
+
}
|
|
190
|
+
return coords;
|
|
191
|
+
}
|
|
192
|
+
var computePosition = async (reference, floating, config) => {
|
|
193
|
+
const {
|
|
194
|
+
placement = "bottom",
|
|
195
|
+
strategy = "absolute",
|
|
196
|
+
middleware = [],
|
|
197
|
+
platform: platform2
|
|
198
|
+
} = config;
|
|
199
|
+
const validMiddleware = middleware.filter(Boolean);
|
|
200
|
+
const rtl = await (platform2.isRTL == null ? void 0 : platform2.isRTL(floating));
|
|
201
|
+
let rects = await platform2.getElementRects({
|
|
202
|
+
reference,
|
|
203
|
+
floating,
|
|
204
|
+
strategy
|
|
205
|
+
});
|
|
206
|
+
let {
|
|
207
|
+
x,
|
|
208
|
+
y
|
|
209
|
+
} = computeCoordsFromPlacement(rects, placement, rtl);
|
|
210
|
+
let statefulPlacement = placement;
|
|
211
|
+
let middlewareData = {};
|
|
212
|
+
let resetCount = 0;
|
|
213
|
+
for (let i = 0; i < validMiddleware.length; i++) {
|
|
214
|
+
const {
|
|
215
|
+
name,
|
|
216
|
+
fn
|
|
217
|
+
} = validMiddleware[i];
|
|
218
|
+
const {
|
|
219
|
+
x: nextX,
|
|
220
|
+
y: nextY,
|
|
221
|
+
data,
|
|
222
|
+
reset
|
|
223
|
+
} = await fn({
|
|
224
|
+
x,
|
|
225
|
+
y,
|
|
226
|
+
initialPlacement: placement,
|
|
227
|
+
placement: statefulPlacement,
|
|
228
|
+
strategy,
|
|
229
|
+
middlewareData,
|
|
230
|
+
rects,
|
|
231
|
+
platform: platform2,
|
|
232
|
+
elements: {
|
|
233
|
+
reference,
|
|
234
|
+
floating
|
|
235
|
+
}
|
|
236
|
+
});
|
|
237
|
+
x = nextX != null ? nextX : x;
|
|
238
|
+
y = nextY != null ? nextY : y;
|
|
239
|
+
middlewareData = {
|
|
240
|
+
...middlewareData,
|
|
241
|
+
[name]: {
|
|
242
|
+
...middlewareData[name],
|
|
243
|
+
...data
|
|
244
|
+
}
|
|
245
|
+
};
|
|
246
|
+
if (reset && resetCount <= 50) {
|
|
247
|
+
resetCount++;
|
|
248
|
+
if (typeof reset === "object") {
|
|
249
|
+
if (reset.placement) {
|
|
250
|
+
statefulPlacement = reset.placement;
|
|
251
|
+
}
|
|
252
|
+
if (reset.rects) {
|
|
253
|
+
rects = reset.rects === true ? await platform2.getElementRects({
|
|
254
|
+
reference,
|
|
255
|
+
floating,
|
|
256
|
+
strategy
|
|
257
|
+
}) : reset.rects;
|
|
258
|
+
}
|
|
259
|
+
({
|
|
260
|
+
x,
|
|
261
|
+
y
|
|
262
|
+
} = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
|
|
263
|
+
}
|
|
264
|
+
i = -1;
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
return {
|
|
268
|
+
x,
|
|
269
|
+
y,
|
|
270
|
+
placement: statefulPlacement,
|
|
271
|
+
strategy,
|
|
272
|
+
middlewareData
|
|
273
|
+
};
|
|
274
|
+
};
|
|
275
|
+
async function detectOverflow(state, options) {
|
|
276
|
+
var _await$platform$isEle;
|
|
277
|
+
if (options === void 0) {
|
|
278
|
+
options = {};
|
|
279
|
+
}
|
|
280
|
+
const {
|
|
281
|
+
x,
|
|
282
|
+
y,
|
|
283
|
+
platform: platform2,
|
|
284
|
+
rects,
|
|
285
|
+
elements,
|
|
286
|
+
strategy
|
|
287
|
+
} = state;
|
|
288
|
+
const {
|
|
289
|
+
boundary = "clippingAncestors",
|
|
290
|
+
rootBoundary = "viewport",
|
|
291
|
+
elementContext = "floating",
|
|
292
|
+
altBoundary = false,
|
|
293
|
+
padding = 0
|
|
294
|
+
} = evaluate(options, state);
|
|
295
|
+
const paddingObject = getPaddingObject(padding);
|
|
296
|
+
const altContext = elementContext === "floating" ? "reference" : "floating";
|
|
297
|
+
const element = elements[altBoundary ? altContext : elementContext];
|
|
298
|
+
const clippingClientRect = rectToClientRect(await platform2.getClippingRect({
|
|
299
|
+
element: ((_await$platform$isEle = await (platform2.isElement == null ? void 0 : platform2.isElement(element))) != null ? _await$platform$isEle : true) ? element : element.contextElement || await (platform2.getDocumentElement == null ? void 0 : platform2.getDocumentElement(elements.floating)),
|
|
300
|
+
boundary,
|
|
301
|
+
rootBoundary,
|
|
302
|
+
strategy
|
|
303
|
+
}));
|
|
304
|
+
const rect = elementContext === "floating" ? {
|
|
305
|
+
x,
|
|
306
|
+
y,
|
|
307
|
+
width: rects.floating.width,
|
|
308
|
+
height: rects.floating.height
|
|
309
|
+
} : rects.reference;
|
|
310
|
+
const offsetParent = await (platform2.getOffsetParent == null ? void 0 : platform2.getOffsetParent(elements.floating));
|
|
311
|
+
const offsetScale = await (platform2.isElement == null ? void 0 : platform2.isElement(offsetParent)) ? await (platform2.getScale == null ? void 0 : platform2.getScale(offsetParent)) || {
|
|
312
|
+
x: 1,
|
|
313
|
+
y: 1
|
|
314
|
+
} : {
|
|
315
|
+
x: 1,
|
|
316
|
+
y: 1
|
|
317
|
+
};
|
|
318
|
+
const elementClientRect = rectToClientRect(platform2.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform2.convertOffsetParentRelativeRectToViewportRelativeRect({
|
|
319
|
+
elements,
|
|
320
|
+
rect,
|
|
321
|
+
offsetParent,
|
|
322
|
+
strategy
|
|
323
|
+
}) : rect);
|
|
324
|
+
return {
|
|
325
|
+
top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
|
|
326
|
+
bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
|
|
327
|
+
left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
|
|
328
|
+
right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
|
|
329
|
+
};
|
|
330
|
+
}
|
|
331
|
+
var arrow = (options) => ({
|
|
332
|
+
name: "arrow",
|
|
333
|
+
options,
|
|
334
|
+
async fn(state) {
|
|
335
|
+
const {
|
|
336
|
+
x,
|
|
337
|
+
y,
|
|
338
|
+
placement,
|
|
339
|
+
rects,
|
|
340
|
+
platform: platform2,
|
|
341
|
+
elements,
|
|
342
|
+
middlewareData
|
|
343
|
+
} = state;
|
|
344
|
+
const {
|
|
345
|
+
element,
|
|
346
|
+
padding = 0
|
|
347
|
+
} = evaluate(options, state) || {};
|
|
348
|
+
if (element == null) {
|
|
349
|
+
return {};
|
|
350
|
+
}
|
|
351
|
+
const paddingObject = getPaddingObject(padding);
|
|
352
|
+
const coords = {
|
|
353
|
+
x,
|
|
354
|
+
y
|
|
355
|
+
};
|
|
356
|
+
const axis = getAlignmentAxis(placement);
|
|
357
|
+
const length = getAxisLength(axis);
|
|
358
|
+
const arrowDimensions = await platform2.getDimensions(element);
|
|
359
|
+
const isYAxis = axis === "y";
|
|
360
|
+
const minProp = isYAxis ? "top" : "left";
|
|
361
|
+
const maxProp = isYAxis ? "bottom" : "right";
|
|
362
|
+
const clientProp = isYAxis ? "clientHeight" : "clientWidth";
|
|
363
|
+
const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length];
|
|
364
|
+
const startDiff = coords[axis] - rects.reference[axis];
|
|
365
|
+
const arrowOffsetParent = await (platform2.getOffsetParent == null ? void 0 : platform2.getOffsetParent(element));
|
|
366
|
+
let clientSize = arrowOffsetParent ? arrowOffsetParent[clientProp] : 0;
|
|
367
|
+
if (!clientSize || !await (platform2.isElement == null ? void 0 : platform2.isElement(arrowOffsetParent))) {
|
|
368
|
+
clientSize = elements.floating[clientProp] || rects.floating[length];
|
|
369
|
+
}
|
|
370
|
+
const centerToReference = endDiff / 2 - startDiff / 2;
|
|
371
|
+
const largestPossiblePadding = clientSize / 2 - arrowDimensions[length] / 2 - 1;
|
|
372
|
+
const minPadding = min(paddingObject[minProp], largestPossiblePadding);
|
|
373
|
+
const maxPadding = min(paddingObject[maxProp], largestPossiblePadding);
|
|
374
|
+
const min$1 = minPadding;
|
|
375
|
+
const max2 = clientSize - arrowDimensions[length] - maxPadding;
|
|
376
|
+
const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
|
|
377
|
+
const offset3 = clamp(min$1, center, max2);
|
|
378
|
+
const shouldAddOffset = !middlewareData.arrow && getAlignment(placement) != null && center !== offset3 && rects.reference[length] / 2 - (center < min$1 ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0;
|
|
379
|
+
const alignmentOffset = shouldAddOffset ? center < min$1 ? center - min$1 : center - max2 : 0;
|
|
380
|
+
return {
|
|
381
|
+
[axis]: coords[axis] + alignmentOffset,
|
|
382
|
+
data: {
|
|
383
|
+
[axis]: offset3,
|
|
384
|
+
centerOffset: center - offset3 - alignmentOffset,
|
|
385
|
+
...shouldAddOffset && {
|
|
386
|
+
alignmentOffset
|
|
387
|
+
}
|
|
388
|
+
},
|
|
389
|
+
reset: shouldAddOffset
|
|
390
|
+
};
|
|
391
|
+
}
|
|
392
|
+
});
|
|
393
|
+
function getPlacementList(alignment, autoAlignment, allowedPlacements) {
|
|
394
|
+
const allowedPlacementsSortedByAlignment = alignment ? [...allowedPlacements.filter((placement) => getAlignment(placement) === alignment), ...allowedPlacements.filter((placement) => getAlignment(placement) !== alignment)] : allowedPlacements.filter((placement) => getSide(placement) === placement);
|
|
395
|
+
return allowedPlacementsSortedByAlignment.filter((placement) => {
|
|
396
|
+
if (alignment) {
|
|
397
|
+
return getAlignment(placement) === alignment || (autoAlignment ? getOppositeAlignmentPlacement(placement) !== placement : false);
|
|
398
|
+
}
|
|
399
|
+
return true;
|
|
400
|
+
});
|
|
401
|
+
}
|
|
402
|
+
var autoPlacement = function(options) {
|
|
403
|
+
if (options === void 0) {
|
|
404
|
+
options = {};
|
|
405
|
+
}
|
|
406
|
+
return {
|
|
407
|
+
name: "autoPlacement",
|
|
408
|
+
options,
|
|
409
|
+
async fn(state) {
|
|
410
|
+
var _middlewareData$autoP, _middlewareData$autoP2, _placementsThatFitOnE;
|
|
411
|
+
const {
|
|
412
|
+
rects,
|
|
413
|
+
middlewareData,
|
|
414
|
+
placement,
|
|
415
|
+
platform: platform2,
|
|
416
|
+
elements
|
|
417
|
+
} = state;
|
|
418
|
+
const {
|
|
419
|
+
crossAxis = false,
|
|
420
|
+
alignment,
|
|
421
|
+
allowedPlacements = placements,
|
|
422
|
+
autoAlignment = true,
|
|
423
|
+
...detectOverflowOptions
|
|
424
|
+
} = evaluate(options, state);
|
|
425
|
+
const placements$1 = alignment !== void 0 || allowedPlacements === placements ? getPlacementList(alignment || null, autoAlignment, allowedPlacements) : allowedPlacements;
|
|
426
|
+
const overflow = await detectOverflow(state, detectOverflowOptions);
|
|
427
|
+
const currentIndex = ((_middlewareData$autoP = middlewareData.autoPlacement) == null ? void 0 : _middlewareData$autoP.index) || 0;
|
|
428
|
+
const currentPlacement = placements$1[currentIndex];
|
|
429
|
+
if (currentPlacement == null) {
|
|
430
|
+
return {};
|
|
431
|
+
}
|
|
432
|
+
const alignmentSides = getAlignmentSides(currentPlacement, rects, await (platform2.isRTL == null ? void 0 : platform2.isRTL(elements.floating)));
|
|
433
|
+
if (placement !== currentPlacement) {
|
|
434
|
+
return {
|
|
435
|
+
reset: {
|
|
436
|
+
placement: placements$1[0]
|
|
437
|
+
}
|
|
438
|
+
};
|
|
439
|
+
}
|
|
440
|
+
const currentOverflows = [overflow[getSide(currentPlacement)], overflow[alignmentSides[0]], overflow[alignmentSides[1]]];
|
|
441
|
+
const allOverflows = [...((_middlewareData$autoP2 = middlewareData.autoPlacement) == null ? void 0 : _middlewareData$autoP2.overflows) || [], {
|
|
442
|
+
placement: currentPlacement,
|
|
443
|
+
overflows: currentOverflows
|
|
444
|
+
}];
|
|
445
|
+
const nextPlacement = placements$1[currentIndex + 1];
|
|
446
|
+
if (nextPlacement) {
|
|
447
|
+
return {
|
|
448
|
+
data: {
|
|
449
|
+
index: currentIndex + 1,
|
|
450
|
+
overflows: allOverflows
|
|
451
|
+
},
|
|
452
|
+
reset: {
|
|
453
|
+
placement: nextPlacement
|
|
454
|
+
}
|
|
455
|
+
};
|
|
456
|
+
}
|
|
457
|
+
const placementsSortedByMostSpace = allOverflows.map((d) => {
|
|
458
|
+
const alignment2 = getAlignment(d.placement);
|
|
459
|
+
return [d.placement, alignment2 && crossAxis ? (
|
|
460
|
+
// Check along the mainAxis and main crossAxis side.
|
|
461
|
+
d.overflows.slice(0, 2).reduce((acc, v) => acc + v, 0)
|
|
462
|
+
) : (
|
|
463
|
+
// Check only the mainAxis.
|
|
464
|
+
d.overflows[0]
|
|
465
|
+
), d.overflows];
|
|
466
|
+
}).sort((a, b) => a[1] - b[1]);
|
|
467
|
+
const placementsThatFitOnEachSide = placementsSortedByMostSpace.filter((d) => d[2].slice(
|
|
468
|
+
0,
|
|
469
|
+
// Aligned placements should not check their opposite crossAxis
|
|
470
|
+
// side.
|
|
471
|
+
getAlignment(d[0]) ? 2 : 3
|
|
472
|
+
).every((v) => v <= 0));
|
|
473
|
+
const resetPlacement = ((_placementsThatFitOnE = placementsThatFitOnEachSide[0]) == null ? void 0 : _placementsThatFitOnE[0]) || placementsSortedByMostSpace[0][0];
|
|
474
|
+
if (resetPlacement !== placement) {
|
|
475
|
+
return {
|
|
476
|
+
data: {
|
|
477
|
+
index: currentIndex + 1,
|
|
478
|
+
overflows: allOverflows
|
|
479
|
+
},
|
|
480
|
+
reset: {
|
|
481
|
+
placement: resetPlacement
|
|
482
|
+
}
|
|
483
|
+
};
|
|
484
|
+
}
|
|
485
|
+
return {};
|
|
486
|
+
}
|
|
487
|
+
};
|
|
488
|
+
};
|
|
489
|
+
var flip = function(options) {
|
|
490
|
+
if (options === void 0) {
|
|
491
|
+
options = {};
|
|
492
|
+
}
|
|
493
|
+
return {
|
|
494
|
+
name: "flip",
|
|
495
|
+
options,
|
|
496
|
+
async fn(state) {
|
|
497
|
+
var _middlewareData$arrow, _middlewareData$flip;
|
|
498
|
+
const {
|
|
499
|
+
placement,
|
|
500
|
+
middlewareData,
|
|
501
|
+
rects,
|
|
502
|
+
initialPlacement,
|
|
503
|
+
platform: platform2,
|
|
504
|
+
elements
|
|
505
|
+
} = state;
|
|
506
|
+
const {
|
|
507
|
+
mainAxis: checkMainAxis = true,
|
|
508
|
+
crossAxis: checkCrossAxis = true,
|
|
509
|
+
fallbackPlacements: specifiedFallbackPlacements,
|
|
510
|
+
fallbackStrategy = "bestFit",
|
|
511
|
+
fallbackAxisSideDirection = "none",
|
|
512
|
+
flipAlignment = true,
|
|
513
|
+
...detectOverflowOptions
|
|
514
|
+
} = evaluate(options, state);
|
|
515
|
+
if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
|
|
516
|
+
return {};
|
|
517
|
+
}
|
|
518
|
+
const side = getSide(placement);
|
|
519
|
+
const initialSideAxis = getSideAxis(initialPlacement);
|
|
520
|
+
const isBasePlacement = getSide(initialPlacement) === initialPlacement;
|
|
521
|
+
const rtl = await (platform2.isRTL == null ? void 0 : platform2.isRTL(elements.floating));
|
|
522
|
+
const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
|
|
523
|
+
const hasFallbackAxisSideDirection = fallbackAxisSideDirection !== "none";
|
|
524
|
+
if (!specifiedFallbackPlacements && hasFallbackAxisSideDirection) {
|
|
525
|
+
fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
|
|
526
|
+
}
|
|
527
|
+
const placements2 = [initialPlacement, ...fallbackPlacements];
|
|
528
|
+
const overflow = await detectOverflow(state, detectOverflowOptions);
|
|
529
|
+
const overflows = [];
|
|
530
|
+
let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
|
|
531
|
+
if (checkMainAxis) {
|
|
532
|
+
overflows.push(overflow[side]);
|
|
533
|
+
}
|
|
534
|
+
if (checkCrossAxis) {
|
|
535
|
+
const sides2 = getAlignmentSides(placement, rects, rtl);
|
|
536
|
+
overflows.push(overflow[sides2[0]], overflow[sides2[1]]);
|
|
537
|
+
}
|
|
538
|
+
overflowsData = [...overflowsData, {
|
|
539
|
+
placement,
|
|
540
|
+
overflows
|
|
541
|
+
}];
|
|
542
|
+
if (!overflows.every((side2) => side2 <= 0)) {
|
|
543
|
+
var _middlewareData$flip2, _overflowsData$filter;
|
|
544
|
+
const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;
|
|
545
|
+
const nextPlacement = placements2[nextIndex];
|
|
546
|
+
if (nextPlacement) {
|
|
547
|
+
return {
|
|
548
|
+
data: {
|
|
549
|
+
index: nextIndex,
|
|
550
|
+
overflows: overflowsData
|
|
551
|
+
},
|
|
552
|
+
reset: {
|
|
553
|
+
placement: nextPlacement
|
|
554
|
+
}
|
|
555
|
+
};
|
|
556
|
+
}
|
|
557
|
+
let resetPlacement = (_overflowsData$filter = overflowsData.filter((d) => d.overflows[0] <= 0).sort((a, b) => a.overflows[1] - b.overflows[1])[0]) == null ? void 0 : _overflowsData$filter.placement;
|
|
558
|
+
if (!resetPlacement) {
|
|
559
|
+
switch (fallbackStrategy) {
|
|
560
|
+
case "bestFit": {
|
|
561
|
+
var _overflowsData$filter2;
|
|
562
|
+
const placement2 = (_overflowsData$filter2 = overflowsData.filter((d) => {
|
|
563
|
+
if (hasFallbackAxisSideDirection) {
|
|
564
|
+
const currentSideAxis = getSideAxis(d.placement);
|
|
565
|
+
return currentSideAxis === initialSideAxis || // Create a bias to the `y` side axis due to horizontal
|
|
566
|
+
// reading directions favoring greater width.
|
|
567
|
+
currentSideAxis === "y";
|
|
568
|
+
}
|
|
569
|
+
return true;
|
|
570
|
+
}).map((d) => [d.placement, d.overflows.filter((overflow2) => overflow2 > 0).reduce((acc, overflow2) => acc + overflow2, 0)]).sort((a, b) => a[1] - b[1])[0]) == null ? void 0 : _overflowsData$filter2[0];
|
|
571
|
+
if (placement2) {
|
|
572
|
+
resetPlacement = placement2;
|
|
573
|
+
}
|
|
574
|
+
break;
|
|
575
|
+
}
|
|
576
|
+
case "initialPlacement":
|
|
577
|
+
resetPlacement = initialPlacement;
|
|
578
|
+
break;
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
if (placement !== resetPlacement) {
|
|
582
|
+
return {
|
|
583
|
+
reset: {
|
|
584
|
+
placement: resetPlacement
|
|
585
|
+
}
|
|
586
|
+
};
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
return {};
|
|
590
|
+
}
|
|
591
|
+
};
|
|
592
|
+
};
|
|
593
|
+
function getSideOffsets(overflow, rect) {
|
|
594
|
+
return {
|
|
595
|
+
top: overflow.top - rect.height,
|
|
596
|
+
right: overflow.right - rect.width,
|
|
597
|
+
bottom: overflow.bottom - rect.height,
|
|
598
|
+
left: overflow.left - rect.width
|
|
599
|
+
};
|
|
600
|
+
}
|
|
601
|
+
function isAnySideFullyClipped(overflow) {
|
|
602
|
+
return sides.some((side) => overflow[side] >= 0);
|
|
603
|
+
}
|
|
604
|
+
var hide = function(options) {
|
|
605
|
+
if (options === void 0) {
|
|
606
|
+
options = {};
|
|
607
|
+
}
|
|
608
|
+
return {
|
|
609
|
+
name: "hide",
|
|
610
|
+
options,
|
|
611
|
+
async fn(state) {
|
|
612
|
+
const {
|
|
613
|
+
rects
|
|
614
|
+
} = state;
|
|
615
|
+
const {
|
|
616
|
+
strategy = "referenceHidden",
|
|
617
|
+
...detectOverflowOptions
|
|
618
|
+
} = evaluate(options, state);
|
|
619
|
+
switch (strategy) {
|
|
620
|
+
case "referenceHidden": {
|
|
621
|
+
const overflow = await detectOverflow(state, {
|
|
622
|
+
...detectOverflowOptions,
|
|
623
|
+
elementContext: "reference"
|
|
624
|
+
});
|
|
625
|
+
const offsets = getSideOffsets(overflow, rects.reference);
|
|
626
|
+
return {
|
|
627
|
+
data: {
|
|
628
|
+
referenceHiddenOffsets: offsets,
|
|
629
|
+
referenceHidden: isAnySideFullyClipped(offsets)
|
|
630
|
+
}
|
|
631
|
+
};
|
|
632
|
+
}
|
|
633
|
+
case "escaped": {
|
|
634
|
+
const overflow = await detectOverflow(state, {
|
|
635
|
+
...detectOverflowOptions,
|
|
636
|
+
altBoundary: true
|
|
637
|
+
});
|
|
638
|
+
const offsets = getSideOffsets(overflow, rects.floating);
|
|
639
|
+
return {
|
|
640
|
+
data: {
|
|
641
|
+
escapedOffsets: offsets,
|
|
642
|
+
escaped: isAnySideFullyClipped(offsets)
|
|
643
|
+
}
|
|
644
|
+
};
|
|
645
|
+
}
|
|
646
|
+
default: {
|
|
647
|
+
return {};
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
};
|
|
652
|
+
};
|
|
653
|
+
function getBoundingRect(rects) {
|
|
654
|
+
const minX = min(...rects.map((rect) => rect.left));
|
|
655
|
+
const minY = min(...rects.map((rect) => rect.top));
|
|
656
|
+
const maxX = max(...rects.map((rect) => rect.right));
|
|
657
|
+
const maxY = max(...rects.map((rect) => rect.bottom));
|
|
658
|
+
return {
|
|
659
|
+
x: minX,
|
|
660
|
+
y: minY,
|
|
661
|
+
width: maxX - minX,
|
|
662
|
+
height: maxY - minY
|
|
663
|
+
};
|
|
664
|
+
}
|
|
665
|
+
function getRectsByLine(rects) {
|
|
666
|
+
const sortedRects = rects.slice().sort((a, b) => a.y - b.y);
|
|
667
|
+
const groups = [];
|
|
668
|
+
let prevRect = null;
|
|
669
|
+
for (let i = 0; i < sortedRects.length; i++) {
|
|
670
|
+
const rect = sortedRects[i];
|
|
671
|
+
if (!prevRect || rect.y - prevRect.y > prevRect.height / 2) {
|
|
672
|
+
groups.push([rect]);
|
|
673
|
+
} else {
|
|
674
|
+
groups[groups.length - 1].push(rect);
|
|
675
|
+
}
|
|
676
|
+
prevRect = rect;
|
|
677
|
+
}
|
|
678
|
+
return groups.map((rect) => rectToClientRect(getBoundingRect(rect)));
|
|
679
|
+
}
|
|
680
|
+
var inline = function(options) {
|
|
681
|
+
if (options === void 0) {
|
|
682
|
+
options = {};
|
|
683
|
+
}
|
|
684
|
+
return {
|
|
685
|
+
name: "inline",
|
|
686
|
+
options,
|
|
687
|
+
async fn(state) {
|
|
688
|
+
const {
|
|
689
|
+
placement,
|
|
690
|
+
elements,
|
|
691
|
+
rects,
|
|
692
|
+
platform: platform2,
|
|
693
|
+
strategy
|
|
694
|
+
} = state;
|
|
695
|
+
const {
|
|
696
|
+
padding = 2,
|
|
697
|
+
x,
|
|
698
|
+
y
|
|
699
|
+
} = evaluate(options, state);
|
|
700
|
+
const nativeClientRects = Array.from(await (platform2.getClientRects == null ? void 0 : platform2.getClientRects(elements.reference)) || []);
|
|
701
|
+
const clientRects = getRectsByLine(nativeClientRects);
|
|
702
|
+
const fallback = rectToClientRect(getBoundingRect(nativeClientRects));
|
|
703
|
+
const paddingObject = getPaddingObject(padding);
|
|
704
|
+
function getBoundingClientRect2() {
|
|
705
|
+
if (clientRects.length === 2 && clientRects[0].left > clientRects[1].right && x != null && y != null) {
|
|
706
|
+
return clientRects.find((rect) => x > rect.left - paddingObject.left && x < rect.right + paddingObject.right && y > rect.top - paddingObject.top && y < rect.bottom + paddingObject.bottom) || fallback;
|
|
707
|
+
}
|
|
708
|
+
if (clientRects.length >= 2) {
|
|
709
|
+
if (getSideAxis(placement) === "y") {
|
|
710
|
+
const firstRect = clientRects[0];
|
|
711
|
+
const lastRect = clientRects[clientRects.length - 1];
|
|
712
|
+
const isTop = getSide(placement) === "top";
|
|
713
|
+
const top2 = firstRect.top;
|
|
714
|
+
const bottom2 = lastRect.bottom;
|
|
715
|
+
const left2 = isTop ? firstRect.left : lastRect.left;
|
|
716
|
+
const right2 = isTop ? firstRect.right : lastRect.right;
|
|
717
|
+
const width2 = right2 - left2;
|
|
718
|
+
const height2 = bottom2 - top2;
|
|
719
|
+
return {
|
|
720
|
+
top: top2,
|
|
721
|
+
bottom: bottom2,
|
|
722
|
+
left: left2,
|
|
723
|
+
right: right2,
|
|
724
|
+
width: width2,
|
|
725
|
+
height: height2,
|
|
726
|
+
x: left2,
|
|
727
|
+
y: top2
|
|
728
|
+
};
|
|
729
|
+
}
|
|
730
|
+
const isLeftSide = getSide(placement) === "left";
|
|
731
|
+
const maxRight = max(...clientRects.map((rect) => rect.right));
|
|
732
|
+
const minLeft = min(...clientRects.map((rect) => rect.left));
|
|
733
|
+
const measureRects = clientRects.filter((rect) => isLeftSide ? rect.left === minLeft : rect.right === maxRight);
|
|
734
|
+
const top = measureRects[0].top;
|
|
735
|
+
const bottom = measureRects[measureRects.length - 1].bottom;
|
|
736
|
+
const left = minLeft;
|
|
737
|
+
const right = maxRight;
|
|
738
|
+
const width = right - left;
|
|
739
|
+
const height = bottom - top;
|
|
740
|
+
return {
|
|
741
|
+
top,
|
|
742
|
+
bottom,
|
|
743
|
+
left,
|
|
744
|
+
right,
|
|
745
|
+
width,
|
|
746
|
+
height,
|
|
747
|
+
x: left,
|
|
748
|
+
y: top
|
|
749
|
+
};
|
|
750
|
+
}
|
|
751
|
+
return fallback;
|
|
752
|
+
}
|
|
753
|
+
const resetRects = await platform2.getElementRects({
|
|
754
|
+
reference: {
|
|
755
|
+
getBoundingClientRect: getBoundingClientRect2
|
|
756
|
+
},
|
|
757
|
+
floating: elements.floating,
|
|
758
|
+
strategy
|
|
759
|
+
});
|
|
760
|
+
if (rects.reference.x !== resetRects.reference.x || rects.reference.y !== resetRects.reference.y || rects.reference.width !== resetRects.reference.width || rects.reference.height !== resetRects.reference.height) {
|
|
761
|
+
return {
|
|
762
|
+
reset: {
|
|
763
|
+
rects: resetRects
|
|
764
|
+
}
|
|
765
|
+
};
|
|
766
|
+
}
|
|
767
|
+
return {};
|
|
768
|
+
}
|
|
769
|
+
};
|
|
770
|
+
};
|
|
771
|
+
async function convertValueToCoords(state, options) {
|
|
772
|
+
const {
|
|
773
|
+
placement,
|
|
774
|
+
platform: platform2,
|
|
775
|
+
elements
|
|
776
|
+
} = state;
|
|
777
|
+
const rtl = await (platform2.isRTL == null ? void 0 : platform2.isRTL(elements.floating));
|
|
778
|
+
const side = getSide(placement);
|
|
779
|
+
const alignment = getAlignment(placement);
|
|
780
|
+
const isVertical = getSideAxis(placement) === "y";
|
|
781
|
+
const mainAxisMulti = ["left", "top"].includes(side) ? -1 : 1;
|
|
782
|
+
const crossAxisMulti = rtl && isVertical ? -1 : 1;
|
|
783
|
+
const rawValue = evaluate(options, state);
|
|
784
|
+
let {
|
|
785
|
+
mainAxis,
|
|
786
|
+
crossAxis,
|
|
787
|
+
alignmentAxis
|
|
788
|
+
} = typeof rawValue === "number" ? {
|
|
789
|
+
mainAxis: rawValue,
|
|
790
|
+
crossAxis: 0,
|
|
791
|
+
alignmentAxis: null
|
|
792
|
+
} : {
|
|
793
|
+
mainAxis: rawValue.mainAxis || 0,
|
|
794
|
+
crossAxis: rawValue.crossAxis || 0,
|
|
795
|
+
alignmentAxis: rawValue.alignmentAxis
|
|
796
|
+
};
|
|
797
|
+
if (alignment && typeof alignmentAxis === "number") {
|
|
798
|
+
crossAxis = alignment === "end" ? alignmentAxis * -1 : alignmentAxis;
|
|
799
|
+
}
|
|
800
|
+
return isVertical ? {
|
|
801
|
+
x: crossAxis * crossAxisMulti,
|
|
802
|
+
y: mainAxis * mainAxisMulti
|
|
803
|
+
} : {
|
|
804
|
+
x: mainAxis * mainAxisMulti,
|
|
805
|
+
y: crossAxis * crossAxisMulti
|
|
806
|
+
};
|
|
807
|
+
}
|
|
808
|
+
var offset = function(options) {
|
|
809
|
+
if (options === void 0) {
|
|
810
|
+
options = 0;
|
|
811
|
+
}
|
|
812
|
+
return {
|
|
813
|
+
name: "offset",
|
|
814
|
+
options,
|
|
815
|
+
async fn(state) {
|
|
816
|
+
var _middlewareData$offse, _middlewareData$arrow;
|
|
817
|
+
const {
|
|
818
|
+
x,
|
|
819
|
+
y,
|
|
820
|
+
placement,
|
|
821
|
+
middlewareData
|
|
822
|
+
} = state;
|
|
823
|
+
const diffCoords = await convertValueToCoords(state, options);
|
|
824
|
+
if (placement === ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse.placement) && (_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
|
|
825
|
+
return {};
|
|
826
|
+
}
|
|
827
|
+
return {
|
|
828
|
+
x: x + diffCoords.x,
|
|
829
|
+
y: y + diffCoords.y,
|
|
830
|
+
data: {
|
|
831
|
+
...diffCoords,
|
|
832
|
+
placement
|
|
833
|
+
}
|
|
834
|
+
};
|
|
835
|
+
}
|
|
836
|
+
};
|
|
837
|
+
};
|
|
838
|
+
var shift = function(options) {
|
|
839
|
+
if (options === void 0) {
|
|
840
|
+
options = {};
|
|
841
|
+
}
|
|
842
|
+
return {
|
|
843
|
+
name: "shift",
|
|
844
|
+
options,
|
|
845
|
+
async fn(state) {
|
|
846
|
+
const {
|
|
847
|
+
x,
|
|
848
|
+
y,
|
|
849
|
+
placement
|
|
850
|
+
} = state;
|
|
851
|
+
const {
|
|
852
|
+
mainAxis: checkMainAxis = true,
|
|
853
|
+
crossAxis: checkCrossAxis = false,
|
|
854
|
+
limiter = {
|
|
855
|
+
fn: (_ref) => {
|
|
856
|
+
let {
|
|
857
|
+
x: x2,
|
|
858
|
+
y: y2
|
|
859
|
+
} = _ref;
|
|
860
|
+
return {
|
|
861
|
+
x: x2,
|
|
862
|
+
y: y2
|
|
863
|
+
};
|
|
864
|
+
}
|
|
865
|
+
},
|
|
866
|
+
...detectOverflowOptions
|
|
867
|
+
} = evaluate(options, state);
|
|
868
|
+
const coords = {
|
|
869
|
+
x,
|
|
870
|
+
y
|
|
871
|
+
};
|
|
872
|
+
const overflow = await detectOverflow(state, detectOverflowOptions);
|
|
873
|
+
const crossAxis = getSideAxis(getSide(placement));
|
|
874
|
+
const mainAxis = getOppositeAxis(crossAxis);
|
|
875
|
+
let mainAxisCoord = coords[mainAxis];
|
|
876
|
+
let crossAxisCoord = coords[crossAxis];
|
|
877
|
+
if (checkMainAxis) {
|
|
878
|
+
const minSide = mainAxis === "y" ? "top" : "left";
|
|
879
|
+
const maxSide = mainAxis === "y" ? "bottom" : "right";
|
|
880
|
+
const min2 = mainAxisCoord + overflow[minSide];
|
|
881
|
+
const max2 = mainAxisCoord - overflow[maxSide];
|
|
882
|
+
mainAxisCoord = clamp(min2, mainAxisCoord, max2);
|
|
883
|
+
}
|
|
884
|
+
if (checkCrossAxis) {
|
|
885
|
+
const minSide = crossAxis === "y" ? "top" : "left";
|
|
886
|
+
const maxSide = crossAxis === "y" ? "bottom" : "right";
|
|
887
|
+
const min2 = crossAxisCoord + overflow[minSide];
|
|
888
|
+
const max2 = crossAxisCoord - overflow[maxSide];
|
|
889
|
+
crossAxisCoord = clamp(min2, crossAxisCoord, max2);
|
|
890
|
+
}
|
|
891
|
+
const limitedCoords = limiter.fn({
|
|
892
|
+
...state,
|
|
893
|
+
[mainAxis]: mainAxisCoord,
|
|
894
|
+
[crossAxis]: crossAxisCoord
|
|
895
|
+
});
|
|
896
|
+
return {
|
|
897
|
+
...limitedCoords,
|
|
898
|
+
data: {
|
|
899
|
+
x: limitedCoords.x - x,
|
|
900
|
+
y: limitedCoords.y - y,
|
|
901
|
+
enabled: {
|
|
902
|
+
[mainAxis]: checkMainAxis,
|
|
903
|
+
[crossAxis]: checkCrossAxis
|
|
904
|
+
}
|
|
905
|
+
}
|
|
906
|
+
};
|
|
907
|
+
}
|
|
908
|
+
};
|
|
909
|
+
};
|
|
910
|
+
var size = function(options) {
|
|
911
|
+
if (options === void 0) {
|
|
912
|
+
options = {};
|
|
913
|
+
}
|
|
914
|
+
return {
|
|
915
|
+
name: "size",
|
|
916
|
+
options,
|
|
917
|
+
async fn(state) {
|
|
918
|
+
var _state$middlewareData, _state$middlewareData2;
|
|
919
|
+
const {
|
|
920
|
+
placement,
|
|
921
|
+
rects,
|
|
922
|
+
platform: platform2,
|
|
923
|
+
elements
|
|
924
|
+
} = state;
|
|
925
|
+
const {
|
|
926
|
+
apply = () => {
|
|
927
|
+
},
|
|
928
|
+
...detectOverflowOptions
|
|
929
|
+
} = evaluate(options, state);
|
|
930
|
+
const overflow = await detectOverflow(state, detectOverflowOptions);
|
|
931
|
+
const side = getSide(placement);
|
|
932
|
+
const alignment = getAlignment(placement);
|
|
933
|
+
const isYAxis = getSideAxis(placement) === "y";
|
|
934
|
+
const {
|
|
935
|
+
width,
|
|
936
|
+
height
|
|
937
|
+
} = rects.floating;
|
|
938
|
+
let heightSide;
|
|
939
|
+
let widthSide;
|
|
940
|
+
if (side === "top" || side === "bottom") {
|
|
941
|
+
heightSide = side;
|
|
942
|
+
widthSide = alignment === (await (platform2.isRTL == null ? void 0 : platform2.isRTL(elements.floating)) ? "start" : "end") ? "left" : "right";
|
|
943
|
+
} else {
|
|
944
|
+
widthSide = side;
|
|
945
|
+
heightSide = alignment === "end" ? "top" : "bottom";
|
|
946
|
+
}
|
|
947
|
+
const maximumClippingHeight = height - overflow.top - overflow.bottom;
|
|
948
|
+
const maximumClippingWidth = width - overflow.left - overflow.right;
|
|
949
|
+
const overflowAvailableHeight = min(height - overflow[heightSide], maximumClippingHeight);
|
|
950
|
+
const overflowAvailableWidth = min(width - overflow[widthSide], maximumClippingWidth);
|
|
951
|
+
const noShift = !state.middlewareData.shift;
|
|
952
|
+
let availableHeight = overflowAvailableHeight;
|
|
953
|
+
let availableWidth = overflowAvailableWidth;
|
|
954
|
+
if ((_state$middlewareData = state.middlewareData.shift) != null && _state$middlewareData.enabled.x) {
|
|
955
|
+
availableWidth = maximumClippingWidth;
|
|
956
|
+
}
|
|
957
|
+
if ((_state$middlewareData2 = state.middlewareData.shift) != null && _state$middlewareData2.enabled.y) {
|
|
958
|
+
availableHeight = maximumClippingHeight;
|
|
959
|
+
}
|
|
960
|
+
if (noShift && !alignment) {
|
|
961
|
+
const xMin = max(overflow.left, 0);
|
|
962
|
+
const xMax = max(overflow.right, 0);
|
|
963
|
+
const yMin = max(overflow.top, 0);
|
|
964
|
+
const yMax = max(overflow.bottom, 0);
|
|
965
|
+
if (isYAxis) {
|
|
966
|
+
availableWidth = width - 2 * (xMin !== 0 || xMax !== 0 ? xMin + xMax : max(overflow.left, overflow.right));
|
|
967
|
+
} else {
|
|
968
|
+
availableHeight = height - 2 * (yMin !== 0 || yMax !== 0 ? yMin + yMax : max(overflow.top, overflow.bottom));
|
|
969
|
+
}
|
|
970
|
+
}
|
|
971
|
+
await apply({
|
|
972
|
+
...state,
|
|
973
|
+
availableWidth,
|
|
974
|
+
availableHeight
|
|
975
|
+
});
|
|
976
|
+
const nextDimensions = await platform2.getDimensions(elements.floating);
|
|
977
|
+
if (width !== nextDimensions.width || height !== nextDimensions.height) {
|
|
978
|
+
return {
|
|
979
|
+
reset: {
|
|
980
|
+
rects: true
|
|
981
|
+
}
|
|
982
|
+
};
|
|
983
|
+
}
|
|
984
|
+
return {};
|
|
985
|
+
}
|
|
986
|
+
};
|
|
987
|
+
};
|
|
988
|
+
|
|
989
|
+
// ../../node_modules/.pnpm/@floating-ui+utils@0.2.9/node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.mjs
|
|
990
|
+
function hasWindow() {
|
|
991
|
+
return typeof window !== "undefined";
|
|
992
|
+
}
|
|
993
|
+
function getNodeName(node) {
|
|
994
|
+
if (isNode(node)) {
|
|
995
|
+
return (node.nodeName || "").toLowerCase();
|
|
996
|
+
}
|
|
997
|
+
return "#document";
|
|
998
|
+
}
|
|
999
|
+
function getWindow(node) {
|
|
1000
|
+
var _node$ownerDocument;
|
|
1001
|
+
return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
|
|
1002
|
+
}
|
|
1003
|
+
function getDocumentElement(node) {
|
|
1004
|
+
var _ref;
|
|
1005
|
+
return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
|
|
1006
|
+
}
|
|
1007
|
+
function isNode(value) {
|
|
1008
|
+
if (!hasWindow()) {
|
|
1009
|
+
return false;
|
|
1010
|
+
}
|
|
1011
|
+
return value instanceof Node || value instanceof getWindow(value).Node;
|
|
1012
|
+
}
|
|
1013
|
+
function isElement(value) {
|
|
1014
|
+
if (!hasWindow()) {
|
|
1015
|
+
return false;
|
|
1016
|
+
}
|
|
1017
|
+
return value instanceof Element || value instanceof getWindow(value).Element;
|
|
1018
|
+
}
|
|
1019
|
+
function isHTMLElement(value) {
|
|
1020
|
+
if (!hasWindow()) {
|
|
1021
|
+
return false;
|
|
1022
|
+
}
|
|
1023
|
+
return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
|
|
1024
|
+
}
|
|
1025
|
+
function isShadowRoot(value) {
|
|
1026
|
+
if (!hasWindow() || typeof ShadowRoot === "undefined") {
|
|
1027
|
+
return false;
|
|
1028
|
+
}
|
|
1029
|
+
return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
|
|
1030
|
+
}
|
|
1031
|
+
function isOverflowElement(element) {
|
|
1032
|
+
const {
|
|
1033
|
+
overflow,
|
|
1034
|
+
overflowX,
|
|
1035
|
+
overflowY,
|
|
1036
|
+
display
|
|
1037
|
+
} = getComputedStyle(element);
|
|
1038
|
+
return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && !["inline", "contents"].includes(display);
|
|
1039
|
+
}
|
|
1040
|
+
function isTableElement(element) {
|
|
1041
|
+
return ["table", "td", "th"].includes(getNodeName(element));
|
|
1042
|
+
}
|
|
1043
|
+
function isTopLayer(element) {
|
|
1044
|
+
return [":popover-open", ":modal"].some((selector) => {
|
|
1045
|
+
try {
|
|
1046
|
+
return element.matches(selector);
|
|
1047
|
+
} catch (e) {
|
|
1048
|
+
return false;
|
|
1049
|
+
}
|
|
1050
|
+
});
|
|
1051
|
+
}
|
|
1052
|
+
function isContainingBlock(elementOrCss) {
|
|
1053
|
+
const webkit = isWebKit();
|
|
1054
|
+
const css = isElement(elementOrCss) ? getComputedStyle(elementOrCss) : elementOrCss;
|
|
1055
|
+
return ["transform", "translate", "scale", "rotate", "perspective"].some((value) => css[value] ? css[value] !== "none" : false) || (css.containerType ? css.containerType !== "normal" : false) || !webkit && (css.backdropFilter ? css.backdropFilter !== "none" : false) || !webkit && (css.filter ? css.filter !== "none" : false) || ["transform", "translate", "scale", "rotate", "perspective", "filter"].some((value) => (css.willChange || "").includes(value)) || ["paint", "layout", "strict", "content"].some((value) => (css.contain || "").includes(value));
|
|
1056
|
+
}
|
|
1057
|
+
function getContainingBlock(element) {
|
|
1058
|
+
let currentNode = getParentNode(element);
|
|
1059
|
+
while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
|
|
1060
|
+
if (isContainingBlock(currentNode)) {
|
|
1061
|
+
return currentNode;
|
|
1062
|
+
} else if (isTopLayer(currentNode)) {
|
|
1063
|
+
return null;
|
|
1064
|
+
}
|
|
1065
|
+
currentNode = getParentNode(currentNode);
|
|
1066
|
+
}
|
|
1067
|
+
return null;
|
|
1068
|
+
}
|
|
1069
|
+
function isWebKit() {
|
|
1070
|
+
if (typeof CSS === "undefined" || !CSS.supports) return false;
|
|
1071
|
+
return CSS.supports("-webkit-backdrop-filter", "none");
|
|
1072
|
+
}
|
|
1073
|
+
function isLastTraversableNode(node) {
|
|
1074
|
+
return ["html", "body", "#document"].includes(getNodeName(node));
|
|
1075
|
+
}
|
|
1076
|
+
function getComputedStyle(element) {
|
|
1077
|
+
return getWindow(element).getComputedStyle(element);
|
|
1078
|
+
}
|
|
1079
|
+
function getNodeScroll(element) {
|
|
1080
|
+
if (isElement(element)) {
|
|
1081
|
+
return {
|
|
1082
|
+
scrollLeft: element.scrollLeft,
|
|
1083
|
+
scrollTop: element.scrollTop
|
|
1084
|
+
};
|
|
1085
|
+
}
|
|
1086
|
+
return {
|
|
1087
|
+
scrollLeft: element.scrollX,
|
|
1088
|
+
scrollTop: element.scrollY
|
|
1089
|
+
};
|
|
1090
|
+
}
|
|
1091
|
+
function getParentNode(node) {
|
|
1092
|
+
if (getNodeName(node) === "html") {
|
|
1093
|
+
return node;
|
|
1094
|
+
}
|
|
1095
|
+
const result = (
|
|
1096
|
+
// Step into the shadow DOM of the parent of a slotted node.
|
|
1097
|
+
node.assignedSlot || // DOM Element detected.
|
|
1098
|
+
node.parentNode || // ShadowRoot detected.
|
|
1099
|
+
isShadowRoot(node) && node.host || // Fallback.
|
|
1100
|
+
getDocumentElement(node)
|
|
1101
|
+
);
|
|
1102
|
+
return isShadowRoot(result) ? result.host : result;
|
|
1103
|
+
}
|
|
1104
|
+
function getNearestOverflowAncestor(node) {
|
|
1105
|
+
const parentNode = getParentNode(node);
|
|
1106
|
+
if (isLastTraversableNode(parentNode)) {
|
|
1107
|
+
return node.ownerDocument ? node.ownerDocument.body : node.body;
|
|
1108
|
+
}
|
|
1109
|
+
if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
|
|
1110
|
+
return parentNode;
|
|
1111
|
+
}
|
|
1112
|
+
return getNearestOverflowAncestor(parentNode);
|
|
1113
|
+
}
|
|
1114
|
+
function getOverflowAncestors(node, list, traverseIframes) {
|
|
1115
|
+
var _node$ownerDocument2;
|
|
1116
|
+
if (list === void 0) {
|
|
1117
|
+
list = [];
|
|
1118
|
+
}
|
|
1119
|
+
if (traverseIframes === void 0) {
|
|
1120
|
+
traverseIframes = true;
|
|
1121
|
+
}
|
|
1122
|
+
const scrollableAncestor = getNearestOverflowAncestor(node);
|
|
1123
|
+
const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
|
|
1124
|
+
const win = getWindow(scrollableAncestor);
|
|
1125
|
+
if (isBody) {
|
|
1126
|
+
const frameElement = getFrameElement(win);
|
|
1127
|
+
return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []);
|
|
1128
|
+
}
|
|
1129
|
+
return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
|
|
1130
|
+
}
|
|
1131
|
+
function getFrameElement(win) {
|
|
1132
|
+
return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null;
|
|
1133
|
+
}
|
|
1134
|
+
|
|
1135
|
+
// ../../node_modules/.pnpm/@floating-ui+dom@1.6.13/node_modules/@floating-ui/dom/dist/floating-ui.dom.mjs
|
|
1136
|
+
function getCssDimensions(element) {
|
|
1137
|
+
const css = getComputedStyle(element);
|
|
1138
|
+
let width = parseFloat(css.width) || 0;
|
|
1139
|
+
let height = parseFloat(css.height) || 0;
|
|
1140
|
+
const hasOffset = isHTMLElement(element);
|
|
1141
|
+
const offsetWidth = hasOffset ? element.offsetWidth : width;
|
|
1142
|
+
const offsetHeight = hasOffset ? element.offsetHeight : height;
|
|
1143
|
+
const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
|
|
1144
|
+
if (shouldFallback) {
|
|
1145
|
+
width = offsetWidth;
|
|
1146
|
+
height = offsetHeight;
|
|
1147
|
+
}
|
|
1148
|
+
return {
|
|
1149
|
+
width,
|
|
1150
|
+
height,
|
|
1151
|
+
$: shouldFallback
|
|
1152
|
+
};
|
|
1153
|
+
}
|
|
1154
|
+
function unwrapElement(element) {
|
|
1155
|
+
return !isElement(element) ? element.contextElement : element;
|
|
1156
|
+
}
|
|
1157
|
+
function getScale(element) {
|
|
1158
|
+
const domElement = unwrapElement(element);
|
|
1159
|
+
if (!isHTMLElement(domElement)) {
|
|
1160
|
+
return createCoords(1);
|
|
1161
|
+
}
|
|
1162
|
+
const rect = domElement.getBoundingClientRect();
|
|
1163
|
+
const {
|
|
1164
|
+
width,
|
|
1165
|
+
height,
|
|
1166
|
+
$
|
|
1167
|
+
} = getCssDimensions(domElement);
|
|
1168
|
+
let x = ($ ? round(rect.width) : rect.width) / width;
|
|
1169
|
+
let y = ($ ? round(rect.height) : rect.height) / height;
|
|
1170
|
+
if (!x || !Number.isFinite(x)) {
|
|
1171
|
+
x = 1;
|
|
1172
|
+
}
|
|
1173
|
+
if (!y || !Number.isFinite(y)) {
|
|
1174
|
+
y = 1;
|
|
1175
|
+
}
|
|
1176
|
+
return {
|
|
1177
|
+
x,
|
|
1178
|
+
y
|
|
1179
|
+
};
|
|
1180
|
+
}
|
|
1181
|
+
var noOffsets = /* @__PURE__ */ createCoords(0);
|
|
1182
|
+
function getVisualOffsets(element) {
|
|
1183
|
+
const win = getWindow(element);
|
|
1184
|
+
if (!isWebKit() || !win.visualViewport) {
|
|
1185
|
+
return noOffsets;
|
|
1186
|
+
}
|
|
1187
|
+
return {
|
|
1188
|
+
x: win.visualViewport.offsetLeft,
|
|
1189
|
+
y: win.visualViewport.offsetTop
|
|
1190
|
+
};
|
|
1191
|
+
}
|
|
1192
|
+
function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {
|
|
1193
|
+
if (isFixed === void 0) {
|
|
1194
|
+
isFixed = false;
|
|
1195
|
+
}
|
|
1196
|
+
if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) {
|
|
1197
|
+
return false;
|
|
1198
|
+
}
|
|
1199
|
+
return isFixed;
|
|
1200
|
+
}
|
|
1201
|
+
function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
|
|
1202
|
+
if (includeScale === void 0) {
|
|
1203
|
+
includeScale = false;
|
|
1204
|
+
}
|
|
1205
|
+
if (isFixedStrategy === void 0) {
|
|
1206
|
+
isFixedStrategy = false;
|
|
1207
|
+
}
|
|
1208
|
+
const clientRect = element.getBoundingClientRect();
|
|
1209
|
+
const domElement = unwrapElement(element);
|
|
1210
|
+
let scale = createCoords(1);
|
|
1211
|
+
if (includeScale) {
|
|
1212
|
+
if (offsetParent) {
|
|
1213
|
+
if (isElement(offsetParent)) {
|
|
1214
|
+
scale = getScale(offsetParent);
|
|
1215
|
+
}
|
|
1216
|
+
} else {
|
|
1217
|
+
scale = getScale(element);
|
|
1218
|
+
}
|
|
1219
|
+
}
|
|
1220
|
+
const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);
|
|
1221
|
+
let x = (clientRect.left + visualOffsets.x) / scale.x;
|
|
1222
|
+
let y = (clientRect.top + visualOffsets.y) / scale.y;
|
|
1223
|
+
let width = clientRect.width / scale.x;
|
|
1224
|
+
let height = clientRect.height / scale.y;
|
|
1225
|
+
if (domElement) {
|
|
1226
|
+
const win = getWindow(domElement);
|
|
1227
|
+
const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
|
|
1228
|
+
let currentWin = win;
|
|
1229
|
+
let currentIFrame = getFrameElement(currentWin);
|
|
1230
|
+
while (currentIFrame && offsetParent && offsetWin !== currentWin) {
|
|
1231
|
+
const iframeScale = getScale(currentIFrame);
|
|
1232
|
+
const iframeRect = currentIFrame.getBoundingClientRect();
|
|
1233
|
+
const css = getComputedStyle(currentIFrame);
|
|
1234
|
+
const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
|
|
1235
|
+
const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
|
|
1236
|
+
x *= iframeScale.x;
|
|
1237
|
+
y *= iframeScale.y;
|
|
1238
|
+
width *= iframeScale.x;
|
|
1239
|
+
height *= iframeScale.y;
|
|
1240
|
+
x += left;
|
|
1241
|
+
y += top;
|
|
1242
|
+
currentWin = getWindow(currentIFrame);
|
|
1243
|
+
currentIFrame = getFrameElement(currentWin);
|
|
1244
|
+
}
|
|
1245
|
+
}
|
|
1246
|
+
return rectToClientRect({
|
|
1247
|
+
width,
|
|
1248
|
+
height,
|
|
1249
|
+
x,
|
|
1250
|
+
y
|
|
1251
|
+
});
|
|
1252
|
+
}
|
|
1253
|
+
function getWindowScrollBarX(element, rect) {
|
|
1254
|
+
const leftScroll = getNodeScroll(element).scrollLeft;
|
|
1255
|
+
if (!rect) {
|
|
1256
|
+
return getBoundingClientRect(getDocumentElement(element)).left + leftScroll;
|
|
1257
|
+
}
|
|
1258
|
+
return rect.left + leftScroll;
|
|
1259
|
+
}
|
|
1260
|
+
function getHTMLOffset(documentElement, scroll, ignoreScrollbarX) {
|
|
1261
|
+
if (ignoreScrollbarX === void 0) {
|
|
1262
|
+
ignoreScrollbarX = false;
|
|
1263
|
+
}
|
|
1264
|
+
const htmlRect = documentElement.getBoundingClientRect();
|
|
1265
|
+
const x = htmlRect.left + scroll.scrollLeft - (ignoreScrollbarX ? 0 : (
|
|
1266
|
+
// RTL <body> scrollbar.
|
|
1267
|
+
getWindowScrollBarX(documentElement, htmlRect)
|
|
1268
|
+
));
|
|
1269
|
+
const y = htmlRect.top + scroll.scrollTop;
|
|
1270
|
+
return {
|
|
1271
|
+
x,
|
|
1272
|
+
y
|
|
1273
|
+
};
|
|
1274
|
+
}
|
|
1275
|
+
function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
|
|
1276
|
+
let {
|
|
1277
|
+
elements,
|
|
1278
|
+
rect,
|
|
1279
|
+
offsetParent,
|
|
1280
|
+
strategy
|
|
1281
|
+
} = _ref;
|
|
1282
|
+
const isFixed = strategy === "fixed";
|
|
1283
|
+
const documentElement = getDocumentElement(offsetParent);
|
|
1284
|
+
const topLayer = elements ? isTopLayer(elements.floating) : false;
|
|
1285
|
+
if (offsetParent === documentElement || topLayer && isFixed) {
|
|
1286
|
+
return rect;
|
|
1287
|
+
}
|
|
1288
|
+
let scroll = {
|
|
1289
|
+
scrollLeft: 0,
|
|
1290
|
+
scrollTop: 0
|
|
1291
|
+
};
|
|
1292
|
+
let scale = createCoords(1);
|
|
1293
|
+
const offsets = createCoords(0);
|
|
1294
|
+
const isOffsetParentAnElement = isHTMLElement(offsetParent);
|
|
1295
|
+
if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
|
|
1296
|
+
if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
|
|
1297
|
+
scroll = getNodeScroll(offsetParent);
|
|
1298
|
+
}
|
|
1299
|
+
if (isHTMLElement(offsetParent)) {
|
|
1300
|
+
const offsetRect = getBoundingClientRect(offsetParent);
|
|
1301
|
+
scale = getScale(offsetParent);
|
|
1302
|
+
offsets.x = offsetRect.x + offsetParent.clientLeft;
|
|
1303
|
+
offsets.y = offsetRect.y + offsetParent.clientTop;
|
|
1304
|
+
}
|
|
1305
|
+
}
|
|
1306
|
+
const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll, true) : createCoords(0);
|
|
1307
|
+
return {
|
|
1308
|
+
width: rect.width * scale.x,
|
|
1309
|
+
height: rect.height * scale.y,
|
|
1310
|
+
x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x + htmlOffset.x,
|
|
1311
|
+
y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y + htmlOffset.y
|
|
1312
|
+
};
|
|
1313
|
+
}
|
|
1314
|
+
function getClientRects(element) {
|
|
1315
|
+
return Array.from(element.getClientRects());
|
|
1316
|
+
}
|
|
1317
|
+
function getDocumentRect(element) {
|
|
1318
|
+
const html = getDocumentElement(element);
|
|
1319
|
+
const scroll = getNodeScroll(element);
|
|
1320
|
+
const body = element.ownerDocument.body;
|
|
1321
|
+
const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);
|
|
1322
|
+
const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
|
|
1323
|
+
let x = -scroll.scrollLeft + getWindowScrollBarX(element);
|
|
1324
|
+
const y = -scroll.scrollTop;
|
|
1325
|
+
if (getComputedStyle(body).direction === "rtl") {
|
|
1326
|
+
x += max(html.clientWidth, body.clientWidth) - width;
|
|
1327
|
+
}
|
|
1328
|
+
return {
|
|
1329
|
+
width,
|
|
1330
|
+
height,
|
|
1331
|
+
x,
|
|
1332
|
+
y
|
|
1333
|
+
};
|
|
1334
|
+
}
|
|
1335
|
+
function getViewportRect(element, strategy) {
|
|
1336
|
+
const win = getWindow(element);
|
|
1337
|
+
const html = getDocumentElement(element);
|
|
1338
|
+
const visualViewport = win.visualViewport;
|
|
1339
|
+
let width = html.clientWidth;
|
|
1340
|
+
let height = html.clientHeight;
|
|
1341
|
+
let x = 0;
|
|
1342
|
+
let y = 0;
|
|
1343
|
+
if (visualViewport) {
|
|
1344
|
+
width = visualViewport.width;
|
|
1345
|
+
height = visualViewport.height;
|
|
1346
|
+
const visualViewportBased = isWebKit();
|
|
1347
|
+
if (!visualViewportBased || visualViewportBased && strategy === "fixed") {
|
|
1348
|
+
x = visualViewport.offsetLeft;
|
|
1349
|
+
y = visualViewport.offsetTop;
|
|
1350
|
+
}
|
|
1351
|
+
}
|
|
1352
|
+
return {
|
|
1353
|
+
width,
|
|
1354
|
+
height,
|
|
1355
|
+
x,
|
|
1356
|
+
y
|
|
1357
|
+
};
|
|
1358
|
+
}
|
|
1359
|
+
function getInnerBoundingClientRect(element, strategy) {
|
|
1360
|
+
const clientRect = getBoundingClientRect(element, true, strategy === "fixed");
|
|
1361
|
+
const top = clientRect.top + element.clientTop;
|
|
1362
|
+
const left = clientRect.left + element.clientLeft;
|
|
1363
|
+
const scale = isHTMLElement(element) ? getScale(element) : createCoords(1);
|
|
1364
|
+
const width = element.clientWidth * scale.x;
|
|
1365
|
+
const height = element.clientHeight * scale.y;
|
|
1366
|
+
const x = left * scale.x;
|
|
1367
|
+
const y = top * scale.y;
|
|
1368
|
+
return {
|
|
1369
|
+
width,
|
|
1370
|
+
height,
|
|
1371
|
+
x,
|
|
1372
|
+
y
|
|
1373
|
+
};
|
|
1374
|
+
}
|
|
1375
|
+
function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
|
|
1376
|
+
let rect;
|
|
1377
|
+
if (clippingAncestor === "viewport") {
|
|
1378
|
+
rect = getViewportRect(element, strategy);
|
|
1379
|
+
} else if (clippingAncestor === "document") {
|
|
1380
|
+
rect = getDocumentRect(getDocumentElement(element));
|
|
1381
|
+
} else if (isElement(clippingAncestor)) {
|
|
1382
|
+
rect = getInnerBoundingClientRect(clippingAncestor, strategy);
|
|
1383
|
+
} else {
|
|
1384
|
+
const visualOffsets = getVisualOffsets(element);
|
|
1385
|
+
rect = {
|
|
1386
|
+
x: clippingAncestor.x - visualOffsets.x,
|
|
1387
|
+
y: clippingAncestor.y - visualOffsets.y,
|
|
1388
|
+
width: clippingAncestor.width,
|
|
1389
|
+
height: clippingAncestor.height
|
|
1390
|
+
};
|
|
1391
|
+
}
|
|
1392
|
+
return rectToClientRect(rect);
|
|
1393
|
+
}
|
|
1394
|
+
function hasFixedPositionAncestor(element, stopNode) {
|
|
1395
|
+
const parentNode = getParentNode(element);
|
|
1396
|
+
if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) {
|
|
1397
|
+
return false;
|
|
1398
|
+
}
|
|
1399
|
+
return getComputedStyle(parentNode).position === "fixed" || hasFixedPositionAncestor(parentNode, stopNode);
|
|
1400
|
+
}
|
|
1401
|
+
function getClippingElementAncestors(element, cache) {
|
|
1402
|
+
const cachedResult = cache.get(element);
|
|
1403
|
+
if (cachedResult) {
|
|
1404
|
+
return cachedResult;
|
|
1405
|
+
}
|
|
1406
|
+
let result = getOverflowAncestors(element, [], false).filter((el) => isElement(el) && getNodeName(el) !== "body");
|
|
1407
|
+
let currentContainingBlockComputedStyle = null;
|
|
1408
|
+
const elementIsFixed = getComputedStyle(element).position === "fixed";
|
|
1409
|
+
let currentNode = elementIsFixed ? getParentNode(element) : element;
|
|
1410
|
+
while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
|
|
1411
|
+
const computedStyle = getComputedStyle(currentNode);
|
|
1412
|
+
const currentNodeIsContaining = isContainingBlock(currentNode);
|
|
1413
|
+
if (!currentNodeIsContaining && computedStyle.position === "fixed") {
|
|
1414
|
+
currentContainingBlockComputedStyle = null;
|
|
1415
|
+
}
|
|
1416
|
+
const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === "static" && !!currentContainingBlockComputedStyle && ["absolute", "fixed"].includes(currentContainingBlockComputedStyle.position) || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode);
|
|
1417
|
+
if (shouldDropCurrentNode) {
|
|
1418
|
+
result = result.filter((ancestor) => ancestor !== currentNode);
|
|
1419
|
+
} else {
|
|
1420
|
+
currentContainingBlockComputedStyle = computedStyle;
|
|
1421
|
+
}
|
|
1422
|
+
currentNode = getParentNode(currentNode);
|
|
1423
|
+
}
|
|
1424
|
+
cache.set(element, result);
|
|
1425
|
+
return result;
|
|
1426
|
+
}
|
|
1427
|
+
function getClippingRect(_ref) {
|
|
1428
|
+
let {
|
|
1429
|
+
element,
|
|
1430
|
+
boundary,
|
|
1431
|
+
rootBoundary,
|
|
1432
|
+
strategy
|
|
1433
|
+
} = _ref;
|
|
1434
|
+
const elementClippingAncestors = boundary === "clippingAncestors" ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary);
|
|
1435
|
+
const clippingAncestors = [...elementClippingAncestors, rootBoundary];
|
|
1436
|
+
const firstClippingAncestor = clippingAncestors[0];
|
|
1437
|
+
const clippingRect = clippingAncestors.reduce((accRect, clippingAncestor) => {
|
|
1438
|
+
const rect = getClientRectFromClippingAncestor(element, clippingAncestor, strategy);
|
|
1439
|
+
accRect.top = max(rect.top, accRect.top);
|
|
1440
|
+
accRect.right = min(rect.right, accRect.right);
|
|
1441
|
+
accRect.bottom = min(rect.bottom, accRect.bottom);
|
|
1442
|
+
accRect.left = max(rect.left, accRect.left);
|
|
1443
|
+
return accRect;
|
|
1444
|
+
}, getClientRectFromClippingAncestor(element, firstClippingAncestor, strategy));
|
|
1445
|
+
return {
|
|
1446
|
+
width: clippingRect.right - clippingRect.left,
|
|
1447
|
+
height: clippingRect.bottom - clippingRect.top,
|
|
1448
|
+
x: clippingRect.left,
|
|
1449
|
+
y: clippingRect.top
|
|
1450
|
+
};
|
|
1451
|
+
}
|
|
1452
|
+
function getDimensions(element) {
|
|
1453
|
+
const {
|
|
1454
|
+
width,
|
|
1455
|
+
height
|
|
1456
|
+
} = getCssDimensions(element);
|
|
1457
|
+
return {
|
|
1458
|
+
width,
|
|
1459
|
+
height
|
|
1460
|
+
};
|
|
1461
|
+
}
|
|
1462
|
+
function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
|
|
1463
|
+
const isOffsetParentAnElement = isHTMLElement(offsetParent);
|
|
1464
|
+
const documentElement = getDocumentElement(offsetParent);
|
|
1465
|
+
const isFixed = strategy === "fixed";
|
|
1466
|
+
const rect = getBoundingClientRect(element, true, isFixed, offsetParent);
|
|
1467
|
+
let scroll = {
|
|
1468
|
+
scrollLeft: 0,
|
|
1469
|
+
scrollTop: 0
|
|
1470
|
+
};
|
|
1471
|
+
const offsets = createCoords(0);
|
|
1472
|
+
if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
|
|
1473
|
+
if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
|
|
1474
|
+
scroll = getNodeScroll(offsetParent);
|
|
1475
|
+
}
|
|
1476
|
+
if (isOffsetParentAnElement) {
|
|
1477
|
+
const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);
|
|
1478
|
+
offsets.x = offsetRect.x + offsetParent.clientLeft;
|
|
1479
|
+
offsets.y = offsetRect.y + offsetParent.clientTop;
|
|
1480
|
+
} else if (documentElement) {
|
|
1481
|
+
offsets.x = getWindowScrollBarX(documentElement);
|
|
1482
|
+
}
|
|
1483
|
+
}
|
|
1484
|
+
const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
|
|
1485
|
+
const x = rect.left + scroll.scrollLeft - offsets.x - htmlOffset.x;
|
|
1486
|
+
const y = rect.top + scroll.scrollTop - offsets.y - htmlOffset.y;
|
|
1487
|
+
return {
|
|
1488
|
+
x,
|
|
1489
|
+
y,
|
|
1490
|
+
width: rect.width,
|
|
1491
|
+
height: rect.height
|
|
1492
|
+
};
|
|
1493
|
+
}
|
|
1494
|
+
function isStaticPositioned(element) {
|
|
1495
|
+
return getComputedStyle(element).position === "static";
|
|
1496
|
+
}
|
|
1497
|
+
function getTrueOffsetParent(element, polyfill) {
|
|
1498
|
+
if (!isHTMLElement(element) || getComputedStyle(element).position === "fixed") {
|
|
1499
|
+
return null;
|
|
1500
|
+
}
|
|
1501
|
+
if (polyfill) {
|
|
1502
|
+
return polyfill(element);
|
|
1503
|
+
}
|
|
1504
|
+
let rawOffsetParent = element.offsetParent;
|
|
1505
|
+
if (getDocumentElement(element) === rawOffsetParent) {
|
|
1506
|
+
rawOffsetParent = rawOffsetParent.ownerDocument.body;
|
|
1507
|
+
}
|
|
1508
|
+
return rawOffsetParent;
|
|
1509
|
+
}
|
|
1510
|
+
function getOffsetParent(element, polyfill) {
|
|
1511
|
+
const win = getWindow(element);
|
|
1512
|
+
if (isTopLayer(element)) {
|
|
1513
|
+
return win;
|
|
1514
|
+
}
|
|
1515
|
+
if (!isHTMLElement(element)) {
|
|
1516
|
+
let svgOffsetParent = getParentNode(element);
|
|
1517
|
+
while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) {
|
|
1518
|
+
if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) {
|
|
1519
|
+
return svgOffsetParent;
|
|
1520
|
+
}
|
|
1521
|
+
svgOffsetParent = getParentNode(svgOffsetParent);
|
|
1522
|
+
}
|
|
1523
|
+
return win;
|
|
1524
|
+
}
|
|
1525
|
+
let offsetParent = getTrueOffsetParent(element, polyfill);
|
|
1526
|
+
while (offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)) {
|
|
1527
|
+
offsetParent = getTrueOffsetParent(offsetParent, polyfill);
|
|
1528
|
+
}
|
|
1529
|
+
if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) {
|
|
1530
|
+
return win;
|
|
1531
|
+
}
|
|
1532
|
+
return offsetParent || getContainingBlock(element) || win;
|
|
1533
|
+
}
|
|
1534
|
+
var getElementRects = async function(data) {
|
|
1535
|
+
const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
|
|
1536
|
+
const getDimensionsFn = this.getDimensions;
|
|
1537
|
+
const floatingDimensions = await getDimensionsFn(data.floating);
|
|
1538
|
+
return {
|
|
1539
|
+
reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy),
|
|
1540
|
+
floating: {
|
|
1541
|
+
x: 0,
|
|
1542
|
+
y: 0,
|
|
1543
|
+
width: floatingDimensions.width,
|
|
1544
|
+
height: floatingDimensions.height
|
|
1545
|
+
}
|
|
1546
|
+
};
|
|
1547
|
+
};
|
|
1548
|
+
function isRTL(element) {
|
|
1549
|
+
return getComputedStyle(element).direction === "rtl";
|
|
1550
|
+
}
|
|
1551
|
+
var platform = {
|
|
1552
|
+
convertOffsetParentRelativeRectToViewportRelativeRect,
|
|
1553
|
+
getDocumentElement,
|
|
1554
|
+
getClippingRect,
|
|
1555
|
+
getOffsetParent,
|
|
1556
|
+
getElementRects,
|
|
1557
|
+
getClientRects,
|
|
1558
|
+
getDimensions,
|
|
1559
|
+
getScale,
|
|
1560
|
+
isElement,
|
|
1561
|
+
isRTL
|
|
1562
|
+
};
|
|
1563
|
+
var offset2 = offset;
|
|
1564
|
+
var autoPlacement2 = autoPlacement;
|
|
1565
|
+
var shift2 = shift;
|
|
1566
|
+
var flip2 = flip;
|
|
1567
|
+
var size2 = size;
|
|
1568
|
+
var hide2 = hide;
|
|
1569
|
+
var arrow2 = arrow;
|
|
1570
|
+
var inline2 = inline;
|
|
1571
|
+
var computePosition2 = (reference, floating, options) => {
|
|
1572
|
+
const cache = /* @__PURE__ */ new Map();
|
|
1573
|
+
const mergedOptions = {
|
|
1574
|
+
platform,
|
|
1575
|
+
...options
|
|
1576
|
+
};
|
|
1577
|
+
const platformWithCache = {
|
|
1578
|
+
...mergedOptions.platform,
|
|
1579
|
+
_c: cache
|
|
1580
|
+
};
|
|
1581
|
+
return computePosition(reference, floating, {
|
|
1582
|
+
...mergedOptions,
|
|
1583
|
+
platform: platformWithCache
|
|
1584
|
+
});
|
|
1585
|
+
};
|
|
1586
|
+
|
|
1587
|
+
// ../extension-bubble-menu/dist/index.js
|
|
1588
|
+
import { isTextSelection, posToDOMRect } from "@tiptap/core";
|
|
1589
|
+
import { Plugin, PluginKey } from "@tiptap/pm/state";
|
|
1590
|
+
import { CellSelection } from "@tiptap/pm/tables";
|
|
1591
|
+
function combineDOMRects(rect1, rect2) {
|
|
1592
|
+
const top = Math.min(rect1.top, rect2.top);
|
|
1593
|
+
const bottom = Math.max(rect1.bottom, rect2.bottom);
|
|
1594
|
+
const left = Math.min(rect1.left, rect2.left);
|
|
1595
|
+
const right = Math.max(rect1.right, rect2.right);
|
|
1596
|
+
const width = right - left;
|
|
1597
|
+
const height = bottom - top;
|
|
1598
|
+
const x = left;
|
|
1599
|
+
const y = top;
|
|
1600
|
+
return new DOMRect(x, y, width, height);
|
|
1601
|
+
}
|
|
1602
|
+
var BubbleMenuView = class {
|
|
1603
|
+
constructor({
|
|
1604
|
+
editor,
|
|
1605
|
+
element,
|
|
1606
|
+
view,
|
|
1607
|
+
updateDelay = 250,
|
|
1608
|
+
resizeDelay = 60,
|
|
1609
|
+
shouldShow,
|
|
1610
|
+
options
|
|
1611
|
+
}) {
|
|
1612
|
+
this.preventHide = false;
|
|
1613
|
+
this.isVisible = false;
|
|
1614
|
+
this.floatingUIOptions = {
|
|
1615
|
+
strategy: "absolute",
|
|
1616
|
+
placement: "top",
|
|
1617
|
+
offset: 8,
|
|
1618
|
+
flip: {},
|
|
1619
|
+
shift: {},
|
|
1620
|
+
arrow: false,
|
|
1621
|
+
size: false,
|
|
1622
|
+
autoPlacement: false,
|
|
1623
|
+
hide: false,
|
|
1624
|
+
inline: false,
|
|
1625
|
+
onShow: void 0,
|
|
1626
|
+
onHide: void 0,
|
|
1627
|
+
onUpdate: void 0,
|
|
1628
|
+
onDestroy: void 0
|
|
1629
|
+
};
|
|
1630
|
+
this.shouldShow = ({ view: view2, state, from, to }) => {
|
|
1631
|
+
const { doc, selection } = state;
|
|
1632
|
+
const { empty } = selection;
|
|
1633
|
+
const isEmptyTextBlock = !doc.textBetween(from, to).length && isTextSelection(state.selection);
|
|
1634
|
+
const isChildOfMenu = this.element.contains(document.activeElement);
|
|
1635
|
+
const hasEditorFocus = view2.hasFocus() || isChildOfMenu;
|
|
1636
|
+
if (!hasEditorFocus || empty || isEmptyTextBlock || !this.editor.isEditable) {
|
|
1637
|
+
return false;
|
|
1638
|
+
}
|
|
1639
|
+
return true;
|
|
1640
|
+
};
|
|
1641
|
+
this.mousedownHandler = () => {
|
|
1642
|
+
this.preventHide = true;
|
|
1643
|
+
};
|
|
1644
|
+
this.dragstartHandler = () => {
|
|
1645
|
+
this.hide();
|
|
1646
|
+
};
|
|
1647
|
+
this.resizeHandler = () => {
|
|
1648
|
+
if (this.resizeDebounceTimer) {
|
|
1649
|
+
clearTimeout(this.resizeDebounceTimer);
|
|
1650
|
+
}
|
|
1651
|
+
this.resizeDebounceTimer = window.setTimeout(() => {
|
|
1652
|
+
this.updatePosition();
|
|
1653
|
+
}, this.resizeDelay);
|
|
1654
|
+
};
|
|
1655
|
+
this.focusHandler = () => {
|
|
1656
|
+
setTimeout(() => this.update(this.editor.view));
|
|
1657
|
+
};
|
|
1658
|
+
this.blurHandler = ({ event }) => {
|
|
1659
|
+
var _a;
|
|
1660
|
+
if (this.preventHide) {
|
|
1661
|
+
this.preventHide = false;
|
|
1662
|
+
return;
|
|
1663
|
+
}
|
|
1664
|
+
if ((event == null ? void 0 : event.relatedTarget) && ((_a = this.element.parentNode) == null ? void 0 : _a.contains(event.relatedTarget))) {
|
|
1665
|
+
return;
|
|
1666
|
+
}
|
|
1667
|
+
if ((event == null ? void 0 : event.relatedTarget) === this.editor.view.dom) {
|
|
1668
|
+
return;
|
|
1669
|
+
}
|
|
1670
|
+
this.hide();
|
|
1671
|
+
};
|
|
1672
|
+
this.handleDebouncedUpdate = (view2, oldState) => {
|
|
1673
|
+
const selectionChanged = !(oldState == null ? void 0 : oldState.selection.eq(view2.state.selection));
|
|
1674
|
+
const docChanged = !(oldState == null ? void 0 : oldState.doc.eq(view2.state.doc));
|
|
1675
|
+
if (!selectionChanged && !docChanged) {
|
|
1676
|
+
return;
|
|
1677
|
+
}
|
|
1678
|
+
if (this.updateDebounceTimer) {
|
|
1679
|
+
clearTimeout(this.updateDebounceTimer);
|
|
1680
|
+
}
|
|
1681
|
+
this.updateDebounceTimer = window.setTimeout(() => {
|
|
1682
|
+
this.updateHandler(view2, selectionChanged, docChanged, oldState);
|
|
1683
|
+
}, this.updateDelay);
|
|
1684
|
+
};
|
|
1685
|
+
this.updateHandler = (view2, selectionChanged, docChanged, oldState) => {
|
|
1686
|
+
const { composing } = view2;
|
|
1687
|
+
const isSame = !selectionChanged && !docChanged;
|
|
1688
|
+
if (composing || isSame) {
|
|
1689
|
+
return;
|
|
1690
|
+
}
|
|
1691
|
+
const shouldShow2 = this.getShouldShow(oldState);
|
|
1692
|
+
if (!shouldShow2) {
|
|
1693
|
+
this.hide();
|
|
1694
|
+
return;
|
|
1695
|
+
}
|
|
1696
|
+
this.updatePosition();
|
|
1697
|
+
this.show();
|
|
1698
|
+
};
|
|
1699
|
+
this.editor = editor;
|
|
1700
|
+
this.element = element;
|
|
1701
|
+
this.view = view;
|
|
1702
|
+
this.updateDelay = updateDelay;
|
|
1703
|
+
this.resizeDelay = resizeDelay;
|
|
1704
|
+
this.floatingUIOptions = {
|
|
1705
|
+
...this.floatingUIOptions,
|
|
1706
|
+
...options
|
|
1707
|
+
};
|
|
1708
|
+
this.element.tabIndex = 0;
|
|
1709
|
+
if (shouldShow) {
|
|
1710
|
+
this.shouldShow = shouldShow;
|
|
1711
|
+
}
|
|
1712
|
+
this.element.addEventListener("mousedown", this.mousedownHandler, { capture: true });
|
|
1713
|
+
this.view.dom.addEventListener("dragstart", this.dragstartHandler);
|
|
1714
|
+
this.editor.on("focus", this.focusHandler);
|
|
1715
|
+
this.editor.on("blur", this.blurHandler);
|
|
1716
|
+
window.addEventListener("resize", this.resizeHandler);
|
|
1717
|
+
this.update(view, view.state);
|
|
1718
|
+
if (this.getShouldShow()) {
|
|
1719
|
+
this.show();
|
|
1720
|
+
}
|
|
1721
|
+
}
|
|
1722
|
+
get middlewares() {
|
|
1723
|
+
const middlewares = [];
|
|
1724
|
+
if (this.floatingUIOptions.flip) {
|
|
1725
|
+
middlewares.push(flip2(typeof this.floatingUIOptions.flip !== "boolean" ? this.floatingUIOptions.flip : void 0));
|
|
1726
|
+
}
|
|
1727
|
+
if (this.floatingUIOptions.shift) {
|
|
1728
|
+
middlewares.push(
|
|
1729
|
+
shift2(typeof this.floatingUIOptions.shift !== "boolean" ? this.floatingUIOptions.shift : void 0)
|
|
1730
|
+
);
|
|
1731
|
+
}
|
|
1732
|
+
if (this.floatingUIOptions.offset) {
|
|
1733
|
+
middlewares.push(
|
|
1734
|
+
offset2(typeof this.floatingUIOptions.offset !== "boolean" ? this.floatingUIOptions.offset : void 0)
|
|
1735
|
+
);
|
|
1736
|
+
}
|
|
1737
|
+
if (this.floatingUIOptions.arrow) {
|
|
1738
|
+
middlewares.push(arrow2(this.floatingUIOptions.arrow));
|
|
1739
|
+
}
|
|
1740
|
+
if (this.floatingUIOptions.size) {
|
|
1741
|
+
middlewares.push(size2(typeof this.floatingUIOptions.size !== "boolean" ? this.floatingUIOptions.size : void 0));
|
|
1742
|
+
}
|
|
1743
|
+
if (this.floatingUIOptions.autoPlacement) {
|
|
1744
|
+
middlewares.push(
|
|
1745
|
+
autoPlacement2(
|
|
1746
|
+
typeof this.floatingUIOptions.autoPlacement !== "boolean" ? this.floatingUIOptions.autoPlacement : void 0
|
|
1747
|
+
)
|
|
1748
|
+
);
|
|
1749
|
+
}
|
|
1750
|
+
if (this.floatingUIOptions.hide) {
|
|
1751
|
+
middlewares.push(hide2(typeof this.floatingUIOptions.hide !== "boolean" ? this.floatingUIOptions.hide : void 0));
|
|
1752
|
+
}
|
|
1753
|
+
if (this.floatingUIOptions.inline) {
|
|
1754
|
+
middlewares.push(
|
|
1755
|
+
inline2(typeof this.floatingUIOptions.inline !== "boolean" ? this.floatingUIOptions.inline : void 0)
|
|
1756
|
+
);
|
|
1757
|
+
}
|
|
1758
|
+
return middlewares;
|
|
1759
|
+
}
|
|
1760
|
+
updatePosition() {
|
|
1761
|
+
const { selection } = this.editor.state;
|
|
1762
|
+
let virtualElement = {
|
|
1763
|
+
getBoundingClientRect: () => posToDOMRect(this.view, selection.from, selection.to)
|
|
1764
|
+
};
|
|
1765
|
+
if (selection instanceof CellSelection) {
|
|
1766
|
+
const { $anchorCell, $headCell } = selection;
|
|
1767
|
+
const from = $anchorCell ? $anchorCell.pos : $headCell.pos;
|
|
1768
|
+
const to = $headCell ? $headCell.pos : $anchorCell.pos;
|
|
1769
|
+
const fromDOM = this.view.nodeDOM(from);
|
|
1770
|
+
const toDOM = this.view.nodeDOM(to);
|
|
1771
|
+
if (!fromDOM || !toDOM) {
|
|
1772
|
+
return;
|
|
1773
|
+
}
|
|
1774
|
+
const clientRect = fromDOM === toDOM ? fromDOM.getBoundingClientRect() : combineDOMRects(
|
|
1775
|
+
fromDOM.getBoundingClientRect(),
|
|
1776
|
+
toDOM.getBoundingClientRect()
|
|
1777
|
+
);
|
|
1778
|
+
virtualElement = {
|
|
1779
|
+
getBoundingClientRect: () => clientRect
|
|
1780
|
+
};
|
|
1781
|
+
}
|
|
1782
|
+
computePosition2(virtualElement, this.element, {
|
|
1783
|
+
placement: this.floatingUIOptions.placement,
|
|
1784
|
+
strategy: this.floatingUIOptions.strategy,
|
|
1785
|
+
middleware: this.middlewares
|
|
1786
|
+
}).then(({ x, y, strategy }) => {
|
|
1787
|
+
this.element.style.width = "max-content";
|
|
1788
|
+
this.element.style.position = strategy;
|
|
1789
|
+
this.element.style.left = `${x}px`;
|
|
1790
|
+
this.element.style.top = `${y}px`;
|
|
1791
|
+
if (this.isVisible && this.floatingUIOptions.onUpdate) {
|
|
1792
|
+
this.floatingUIOptions.onUpdate();
|
|
1793
|
+
}
|
|
1794
|
+
});
|
|
1795
|
+
}
|
|
1796
|
+
update(view, oldState) {
|
|
1797
|
+
const { state } = view;
|
|
1798
|
+
const hasValidSelection = state.selection.from !== state.selection.to;
|
|
1799
|
+
if (this.updateDelay > 0 && hasValidSelection) {
|
|
1800
|
+
this.handleDebouncedUpdate(view, oldState);
|
|
1801
|
+
return;
|
|
1802
|
+
}
|
|
1803
|
+
const selectionChanged = !(oldState == null ? void 0 : oldState.selection.eq(view.state.selection));
|
|
1804
|
+
const docChanged = !(oldState == null ? void 0 : oldState.doc.eq(view.state.doc));
|
|
1805
|
+
this.updateHandler(view, selectionChanged, docChanged, oldState);
|
|
1806
|
+
}
|
|
1807
|
+
getShouldShow(oldState) {
|
|
1808
|
+
var _a;
|
|
1809
|
+
const { state } = this.view;
|
|
1810
|
+
const { selection } = state;
|
|
1811
|
+
const { ranges } = selection;
|
|
1812
|
+
const from = Math.min(...ranges.map((range) => range.$from.pos));
|
|
1813
|
+
const to = Math.max(...ranges.map((range) => range.$to.pos));
|
|
1814
|
+
const shouldShow = (_a = this.shouldShow) == null ? void 0 : _a.call(this, {
|
|
1815
|
+
editor: this.editor,
|
|
1816
|
+
element: this.element,
|
|
1817
|
+
view: this.view,
|
|
1818
|
+
state,
|
|
1819
|
+
oldState,
|
|
1820
|
+
from,
|
|
1821
|
+
to
|
|
1822
|
+
});
|
|
1823
|
+
return shouldShow;
|
|
1824
|
+
}
|
|
1825
|
+
show() {
|
|
1826
|
+
var _a;
|
|
1827
|
+
if (this.isVisible) {
|
|
1828
|
+
return;
|
|
1829
|
+
}
|
|
1830
|
+
this.element.style.visibility = "visible";
|
|
1831
|
+
this.element.style.opacity = "1";
|
|
1832
|
+
(_a = this.view.dom.parentElement) == null ? void 0 : _a.appendChild(this.element);
|
|
1833
|
+
if (this.floatingUIOptions.onShow) {
|
|
1834
|
+
this.floatingUIOptions.onShow();
|
|
1835
|
+
}
|
|
1836
|
+
this.isVisible = true;
|
|
1837
|
+
}
|
|
1838
|
+
hide() {
|
|
1839
|
+
if (!this.isVisible) {
|
|
1840
|
+
return;
|
|
1841
|
+
}
|
|
1842
|
+
this.element.style.visibility = "hidden";
|
|
1843
|
+
this.element.style.opacity = "0";
|
|
1844
|
+
this.element.remove();
|
|
1845
|
+
if (this.floatingUIOptions.onHide) {
|
|
1846
|
+
this.floatingUIOptions.onHide();
|
|
1847
|
+
}
|
|
1848
|
+
this.isVisible = false;
|
|
1849
|
+
}
|
|
1850
|
+
destroy() {
|
|
1851
|
+
this.hide();
|
|
1852
|
+
this.element.removeEventListener("mousedown", this.mousedownHandler, { capture: true });
|
|
1853
|
+
this.view.dom.removeEventListener("dragstart", this.dragstartHandler);
|
|
1854
|
+
window.removeEventListener("resize", this.resizeHandler);
|
|
1855
|
+
this.editor.off("focus", this.focusHandler);
|
|
1856
|
+
this.editor.off("blur", this.blurHandler);
|
|
1857
|
+
if (this.floatingUIOptions.onDestroy) {
|
|
1858
|
+
this.floatingUIOptions.onDestroy();
|
|
1859
|
+
}
|
|
1860
|
+
}
|
|
1861
|
+
};
|
|
1862
|
+
var BubbleMenuPlugin = (options) => {
|
|
1863
|
+
return new Plugin({
|
|
1864
|
+
key: typeof options.pluginKey === "string" ? new PluginKey(options.pluginKey) : options.pluginKey,
|
|
1865
|
+
view: (view) => new BubbleMenuView({ view, ...options })
|
|
1866
|
+
});
|
|
1867
|
+
};
|
|
1868
|
+
var BubbleMenu = Extension.create({
|
|
1869
|
+
name: "bubbleMenu",
|
|
1870
|
+
addOptions() {
|
|
1871
|
+
return {
|
|
1872
|
+
element: null,
|
|
1873
|
+
pluginKey: "bubbleMenu",
|
|
1874
|
+
updateDelay: void 0,
|
|
1875
|
+
shouldShow: null
|
|
1876
|
+
};
|
|
1877
|
+
},
|
|
1878
|
+
addProseMirrorPlugins() {
|
|
1879
|
+
if (!this.options.element) {
|
|
1880
|
+
return [];
|
|
1881
|
+
}
|
|
1882
|
+
return [
|
|
1883
|
+
BubbleMenuPlugin({
|
|
1884
|
+
pluginKey: this.options.pluginKey,
|
|
1885
|
+
editor: this.editor,
|
|
1886
|
+
element: this.options.element,
|
|
1887
|
+
updateDelay: this.options.updateDelay,
|
|
1888
|
+
shouldShow: this.options.shouldShow
|
|
1889
|
+
})
|
|
1890
|
+
];
|
|
1891
|
+
}
|
|
1892
|
+
});
|
|
1893
|
+
|
|
1894
|
+
// src/menus/BubbleMenu.ts
|
|
1895
|
+
var BubbleMenu2 = {
|
|
1896
|
+
name: "BubbleMenu",
|
|
1897
|
+
props: {
|
|
1898
|
+
pluginKey: {
|
|
1899
|
+
type: [String, Object],
|
|
1900
|
+
default: "bubbleMenu"
|
|
1901
|
+
},
|
|
1902
|
+
editor: {
|
|
1903
|
+
type: Object,
|
|
1904
|
+
required: true
|
|
1905
|
+
},
|
|
1906
|
+
updateDelay: {
|
|
1907
|
+
type: Number
|
|
1908
|
+
},
|
|
1909
|
+
options: {
|
|
1910
|
+
type: Object,
|
|
1911
|
+
default: {}
|
|
1912
|
+
},
|
|
1913
|
+
resizeDelay: {
|
|
1914
|
+
type: Number
|
|
1915
|
+
},
|
|
1916
|
+
shouldShow: {
|
|
1917
|
+
type: Function,
|
|
1918
|
+
default: null
|
|
1919
|
+
}
|
|
1920
|
+
},
|
|
1921
|
+
watch: {
|
|
1922
|
+
editor: {
|
|
1923
|
+
immediate: true,
|
|
1924
|
+
handler(editor) {
|
|
1925
|
+
if (!editor) {
|
|
1926
|
+
return;
|
|
1927
|
+
}
|
|
1928
|
+
;
|
|
1929
|
+
this.$el.style.visibility = "hidden";
|
|
1930
|
+
this.$el.style.position = "absolute";
|
|
1931
|
+
this.$el.remove();
|
|
1932
|
+
this.$nextTick(() => {
|
|
1933
|
+
editor.registerPlugin(
|
|
1934
|
+
BubbleMenuPlugin({
|
|
1935
|
+
updateDelay: this.updateDelay,
|
|
1936
|
+
resizeDelay: this.resizeDelay,
|
|
1937
|
+
options: this.options,
|
|
1938
|
+
editor,
|
|
1939
|
+
element: this.$el,
|
|
1940
|
+
pluginKey: this.pluginKey,
|
|
1941
|
+
shouldShow: this.shouldShow
|
|
1942
|
+
})
|
|
1943
|
+
);
|
|
1944
|
+
});
|
|
1945
|
+
}
|
|
1946
|
+
}
|
|
1947
|
+
},
|
|
1948
|
+
render(createElement) {
|
|
1949
|
+
return createElement("div", { style: { visibility: "hidden" } }, this.$slots.default);
|
|
1950
|
+
},
|
|
1951
|
+
beforeDestroy() {
|
|
1952
|
+
this.editor.unregisterPlugin(this.pluginKey);
|
|
1953
|
+
}
|
|
1954
|
+
};
|
|
1955
|
+
|
|
1956
|
+
// ../extension-floating-menu/dist/index.js
|
|
1957
|
+
import { Extension as Extension2 } from "@tiptap/core";
|
|
1958
|
+
import { getText, getTextSerializersFromSchema, posToDOMRect as posToDOMRect2 } from "@tiptap/core";
|
|
1959
|
+
import { Plugin as Plugin2, PluginKey as PluginKey2 } from "@tiptap/pm/state";
|
|
1960
|
+
var FloatingMenuView = class {
|
|
1961
|
+
constructor({ editor, element, view, options, shouldShow }) {
|
|
1962
|
+
this.preventHide = false;
|
|
1963
|
+
this.isVisible = false;
|
|
1964
|
+
this.shouldShow = ({ view: view2, state }) => {
|
|
1965
|
+
const { selection } = state;
|
|
1966
|
+
const { $anchor, empty } = selection;
|
|
1967
|
+
const isRootDepth = $anchor.depth === 1;
|
|
1968
|
+
const isEmptyTextBlock = $anchor.parent.isTextblock && !$anchor.parent.type.spec.code && !$anchor.parent.textContent && $anchor.parent.childCount === 0 && !this.getTextContent($anchor.parent);
|
|
1969
|
+
if (!view2.hasFocus() || !empty || !isRootDepth || !isEmptyTextBlock || !this.editor.isEditable) {
|
|
1970
|
+
return false;
|
|
1971
|
+
}
|
|
1972
|
+
return true;
|
|
1973
|
+
};
|
|
1974
|
+
this.floatingUIOptions = {
|
|
1975
|
+
strategy: "absolute",
|
|
1976
|
+
placement: "right",
|
|
1977
|
+
offset: 8,
|
|
1978
|
+
flip: {},
|
|
1979
|
+
shift: {},
|
|
1980
|
+
arrow: false,
|
|
1981
|
+
size: false,
|
|
1982
|
+
autoPlacement: false,
|
|
1983
|
+
hide: false,
|
|
1984
|
+
inline: false
|
|
1985
|
+
};
|
|
1986
|
+
this.updateHandler = (view2, selectionChanged, docChanged, oldState) => {
|
|
1987
|
+
const { composing } = view2;
|
|
1988
|
+
const isSame = !selectionChanged && !docChanged;
|
|
1989
|
+
if (composing || isSame) {
|
|
1990
|
+
return;
|
|
1991
|
+
}
|
|
1992
|
+
const shouldShow2 = this.getShouldShow(oldState);
|
|
1993
|
+
if (!shouldShow2) {
|
|
1994
|
+
this.hide();
|
|
1995
|
+
return;
|
|
1996
|
+
}
|
|
1997
|
+
this.updatePosition();
|
|
1998
|
+
this.show();
|
|
1999
|
+
};
|
|
2000
|
+
this.mousedownHandler = () => {
|
|
2001
|
+
this.preventHide = true;
|
|
2002
|
+
};
|
|
2003
|
+
this.focusHandler = () => {
|
|
2004
|
+
setTimeout(() => this.update(this.editor.view));
|
|
2005
|
+
};
|
|
2006
|
+
this.blurHandler = ({ event }) => {
|
|
2007
|
+
var _a;
|
|
2008
|
+
if (this.preventHide) {
|
|
2009
|
+
this.preventHide = false;
|
|
2010
|
+
return;
|
|
2011
|
+
}
|
|
2012
|
+
if ((event == null ? void 0 : event.relatedTarget) && ((_a = this.element.parentNode) == null ? void 0 : _a.contains(event.relatedTarget))) {
|
|
2013
|
+
return;
|
|
2014
|
+
}
|
|
2015
|
+
if ((event == null ? void 0 : event.relatedTarget) === this.editor.view.dom) {
|
|
2016
|
+
return;
|
|
2017
|
+
}
|
|
2018
|
+
this.hide();
|
|
2019
|
+
};
|
|
2020
|
+
this.editor = editor;
|
|
2021
|
+
this.element = element;
|
|
2022
|
+
this.view = view;
|
|
2023
|
+
this.floatingUIOptions = {
|
|
2024
|
+
...this.floatingUIOptions,
|
|
2025
|
+
...options
|
|
2026
|
+
};
|
|
2027
|
+
this.element.tabIndex = 0;
|
|
2028
|
+
if (shouldShow) {
|
|
2029
|
+
this.shouldShow = shouldShow;
|
|
2030
|
+
}
|
|
2031
|
+
this.element.addEventListener("mousedown", this.mousedownHandler, { capture: true });
|
|
2032
|
+
this.editor.on("focus", this.focusHandler);
|
|
2033
|
+
this.editor.on("blur", this.blurHandler);
|
|
2034
|
+
this.update(view, view.state);
|
|
2035
|
+
if (this.getShouldShow()) {
|
|
2036
|
+
this.show();
|
|
2037
|
+
}
|
|
2038
|
+
}
|
|
2039
|
+
getTextContent(node) {
|
|
2040
|
+
return getText(node, { textSerializers: getTextSerializersFromSchema(this.editor.schema) });
|
|
2041
|
+
}
|
|
2042
|
+
get middlewares() {
|
|
2043
|
+
const middlewares = [];
|
|
2044
|
+
if (this.floatingUIOptions.flip) {
|
|
2045
|
+
middlewares.push(flip2(typeof this.floatingUIOptions.flip !== "boolean" ? this.floatingUIOptions.flip : void 0));
|
|
2046
|
+
}
|
|
2047
|
+
if (this.floatingUIOptions.shift) {
|
|
2048
|
+
middlewares.push(
|
|
2049
|
+
shift2(typeof this.floatingUIOptions.shift !== "boolean" ? this.floatingUIOptions.shift : void 0)
|
|
2050
|
+
);
|
|
2051
|
+
}
|
|
2052
|
+
if (this.floatingUIOptions.offset) {
|
|
2053
|
+
middlewares.push(
|
|
2054
|
+
offset2(typeof this.floatingUIOptions.offset !== "boolean" ? this.floatingUIOptions.offset : void 0)
|
|
2055
|
+
);
|
|
2056
|
+
}
|
|
2057
|
+
if (this.floatingUIOptions.arrow) {
|
|
2058
|
+
middlewares.push(arrow2(this.floatingUIOptions.arrow));
|
|
2059
|
+
}
|
|
2060
|
+
if (this.floatingUIOptions.size) {
|
|
2061
|
+
middlewares.push(size2(typeof this.floatingUIOptions.size !== "boolean" ? this.floatingUIOptions.size : void 0));
|
|
2062
|
+
}
|
|
2063
|
+
if (this.floatingUIOptions.autoPlacement) {
|
|
2064
|
+
middlewares.push(
|
|
2065
|
+
autoPlacement2(
|
|
2066
|
+
typeof this.floatingUIOptions.autoPlacement !== "boolean" ? this.floatingUIOptions.autoPlacement : void 0
|
|
2067
|
+
)
|
|
2068
|
+
);
|
|
2069
|
+
}
|
|
2070
|
+
if (this.floatingUIOptions.hide) {
|
|
2071
|
+
middlewares.push(hide2(typeof this.floatingUIOptions.hide !== "boolean" ? this.floatingUIOptions.hide : void 0));
|
|
2072
|
+
}
|
|
2073
|
+
if (this.floatingUIOptions.inline) {
|
|
2074
|
+
middlewares.push(
|
|
2075
|
+
inline2(typeof this.floatingUIOptions.inline !== "boolean" ? this.floatingUIOptions.inline : void 0)
|
|
2076
|
+
);
|
|
2077
|
+
}
|
|
2078
|
+
return middlewares;
|
|
2079
|
+
}
|
|
2080
|
+
getShouldShow(oldState) {
|
|
2081
|
+
var _a;
|
|
2082
|
+
const { state } = this.view;
|
|
2083
|
+
const { selection } = state;
|
|
2084
|
+
const { ranges } = selection;
|
|
2085
|
+
const from = Math.min(...ranges.map((range) => range.$from.pos));
|
|
2086
|
+
const to = Math.max(...ranges.map((range) => range.$to.pos));
|
|
2087
|
+
const shouldShow = (_a = this.shouldShow) == null ? void 0 : _a.call(this, {
|
|
2088
|
+
editor: this.editor,
|
|
2089
|
+
view: this.view,
|
|
2090
|
+
state,
|
|
2091
|
+
oldState,
|
|
2092
|
+
from,
|
|
2093
|
+
to
|
|
2094
|
+
});
|
|
2095
|
+
return shouldShow;
|
|
2096
|
+
}
|
|
2097
|
+
updatePosition() {
|
|
2098
|
+
const { selection } = this.editor.state;
|
|
2099
|
+
const virtualElement = {
|
|
2100
|
+
getBoundingClientRect: () => posToDOMRect2(this.view, selection.from, selection.to)
|
|
2101
|
+
};
|
|
2102
|
+
computePosition2(virtualElement, this.element, {
|
|
2103
|
+
placement: this.floatingUIOptions.placement,
|
|
2104
|
+
strategy: this.floatingUIOptions.strategy,
|
|
2105
|
+
middleware: this.middlewares
|
|
2106
|
+
}).then(({ x, y, strategy }) => {
|
|
2107
|
+
this.element.style.width = "max-content";
|
|
2108
|
+
this.element.style.position = strategy;
|
|
2109
|
+
this.element.style.left = `${x}px`;
|
|
2110
|
+
this.element.style.top = `${y}px`;
|
|
2111
|
+
if (this.isVisible && this.floatingUIOptions.onUpdate) {
|
|
2112
|
+
this.floatingUIOptions.onUpdate();
|
|
2113
|
+
}
|
|
2114
|
+
});
|
|
2115
|
+
}
|
|
2116
|
+
update(view, oldState) {
|
|
2117
|
+
const selectionChanged = !(oldState == null ? void 0 : oldState.selection.eq(view.state.selection));
|
|
2118
|
+
const docChanged = !(oldState == null ? void 0 : oldState.doc.eq(view.state.doc));
|
|
2119
|
+
this.updateHandler(view, selectionChanged, docChanged, oldState);
|
|
2120
|
+
}
|
|
2121
|
+
show() {
|
|
2122
|
+
var _a;
|
|
2123
|
+
if (this.isVisible) {
|
|
2124
|
+
return;
|
|
2125
|
+
}
|
|
2126
|
+
this.element.style.visibility = "visible";
|
|
2127
|
+
this.element.style.opacity = "1";
|
|
2128
|
+
(_a = this.view.dom.parentElement) == null ? void 0 : _a.appendChild(this.element);
|
|
2129
|
+
if (this.floatingUIOptions.onShow) {
|
|
2130
|
+
this.floatingUIOptions.onShow();
|
|
2131
|
+
}
|
|
2132
|
+
this.isVisible = true;
|
|
2133
|
+
}
|
|
2134
|
+
hide() {
|
|
2135
|
+
if (!this.isVisible) {
|
|
2136
|
+
return;
|
|
2137
|
+
}
|
|
2138
|
+
this.element.style.visibility = "hidden";
|
|
2139
|
+
this.element.style.opacity = "0";
|
|
2140
|
+
this.element.remove();
|
|
2141
|
+
if (this.floatingUIOptions.onHide) {
|
|
2142
|
+
this.floatingUIOptions.onHide();
|
|
2143
|
+
}
|
|
2144
|
+
this.isVisible = false;
|
|
2145
|
+
}
|
|
2146
|
+
destroy() {
|
|
2147
|
+
this.hide();
|
|
2148
|
+
this.element.removeEventListener("mousedown", this.mousedownHandler, { capture: true });
|
|
2149
|
+
this.editor.off("focus", this.focusHandler);
|
|
2150
|
+
this.editor.off("blur", this.blurHandler);
|
|
2151
|
+
if (this.floatingUIOptions.onDestroy) {
|
|
2152
|
+
this.floatingUIOptions.onDestroy();
|
|
2153
|
+
}
|
|
2154
|
+
}
|
|
2155
|
+
};
|
|
2156
|
+
var FloatingMenuPlugin = (options) => {
|
|
2157
|
+
return new Plugin2({
|
|
2158
|
+
key: typeof options.pluginKey === "string" ? new PluginKey2(options.pluginKey) : options.pluginKey,
|
|
2159
|
+
view: (view) => new FloatingMenuView({ view, ...options })
|
|
2160
|
+
});
|
|
2161
|
+
};
|
|
2162
|
+
var FloatingMenu = Extension2.create({
|
|
2163
|
+
name: "floatingMenu",
|
|
2164
|
+
addOptions() {
|
|
2165
|
+
return {
|
|
2166
|
+
element: null,
|
|
2167
|
+
options: {},
|
|
2168
|
+
pluginKey: "floatingMenu",
|
|
2169
|
+
shouldShow: null
|
|
2170
|
+
};
|
|
2171
|
+
},
|
|
2172
|
+
addProseMirrorPlugins() {
|
|
2173
|
+
if (!this.options.element) {
|
|
2174
|
+
return [];
|
|
2175
|
+
}
|
|
2176
|
+
return [
|
|
2177
|
+
FloatingMenuPlugin({
|
|
2178
|
+
pluginKey: this.options.pluginKey,
|
|
2179
|
+
editor: this.editor,
|
|
2180
|
+
element: this.options.element,
|
|
2181
|
+
options: this.options.options,
|
|
2182
|
+
shouldShow: this.options.shouldShow
|
|
2183
|
+
})
|
|
2184
|
+
];
|
|
2185
|
+
}
|
|
2186
|
+
});
|
|
2187
|
+
|
|
2188
|
+
// src/menus/FloatingMenu.ts
|
|
2189
|
+
var FloatingMenu2 = {
|
|
2190
|
+
name: "FloatingMenu",
|
|
2191
|
+
props: {
|
|
2192
|
+
pluginKey: {
|
|
2193
|
+
type: [String, Object],
|
|
2194
|
+
default: "floatingMenu"
|
|
2195
|
+
},
|
|
2196
|
+
editor: {
|
|
2197
|
+
type: Object,
|
|
2198
|
+
required: true
|
|
2199
|
+
},
|
|
2200
|
+
options: {
|
|
2201
|
+
type: Object,
|
|
2202
|
+
default: () => ({})
|
|
2203
|
+
},
|
|
2204
|
+
shouldShow: {
|
|
2205
|
+
type: Function,
|
|
2206
|
+
default: null
|
|
2207
|
+
}
|
|
2208
|
+
},
|
|
2209
|
+
watch: {
|
|
2210
|
+
editor: {
|
|
2211
|
+
immediate: true,
|
|
2212
|
+
handler(editor) {
|
|
2213
|
+
if (!editor) {
|
|
2214
|
+
return;
|
|
2215
|
+
}
|
|
2216
|
+
;
|
|
2217
|
+
this.$el.style.visibility = "hidden";
|
|
2218
|
+
this.$el.style.position = "absolute";
|
|
2219
|
+
this.$el.remove();
|
|
2220
|
+
this.$nextTick(() => {
|
|
2221
|
+
editor.registerPlugin(
|
|
2222
|
+
FloatingMenuPlugin({
|
|
2223
|
+
pluginKey: this.pluginKey,
|
|
2224
|
+
editor,
|
|
2225
|
+
element: this.$el,
|
|
2226
|
+
options: this.options,
|
|
2227
|
+
shouldShow: this.shouldShow
|
|
2228
|
+
})
|
|
2229
|
+
);
|
|
2230
|
+
});
|
|
2231
|
+
}
|
|
2232
|
+
}
|
|
2233
|
+
},
|
|
2234
|
+
render(createElement) {
|
|
2235
|
+
return createElement("div", { style: { visibility: "hidden" } }, this.$slots.default);
|
|
2236
|
+
},
|
|
2237
|
+
beforeDestroy() {
|
|
2238
|
+
this.editor.unregisterPlugin(this.pluginKey);
|
|
2239
|
+
}
|
|
2240
|
+
};
|
|
2241
|
+
export {
|
|
2242
|
+
BubbleMenu2 as BubbleMenu,
|
|
2243
|
+
FloatingMenu2 as FloatingMenu
|
|
2244
|
+
};
|
|
2245
|
+
//# sourceMappingURL=index.js.map
|