@edifice.io/react 2.6.10-develop-pedago.20261022131512 → 2.6.10-develop.20261023111140
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/dist/editor.js +0 -2
- package/dist/modules/editor/components/BubbleMenuEditImage/BubbleMenuEditImage.js +91 -110
- package/dist/modules/editor/components/BubbleMenuEditInformationPane/BubbleMenuEditInformationPane.js +96 -123
- package/dist/modules/editor/components/EditorToolbar/EditorToolbar.HighlightColor.js +8 -5
- package/dist/modules/editor/components/EditorToolbar/EditorToolbar.TextColor.js +8 -5
- package/dist/modules/editor/components/EditorToolbar/EditorToolbar.Typography.js +2 -3
- package/dist/modules/editor/components/EditorToolbar/EditorToolbar.js +4 -6
- package/dist/modules/editor/components/Toolbar/LinkToolbar.TippyOptions.d.ts +2 -0
- package/dist/modules/editor/components/Toolbar/LinkToolbar.TippyOptions.js +8 -0
- package/dist/modules/editor/components/Toolbar/LinkToolbar.d.ts +3 -6
- package/dist/modules/editor/components/Toolbar/LinkToolbar.js +7 -29
- package/dist/modules/editor/components/Toolbar/TableToolbar.CellColor.js +2 -3
- package/dist/modules/editor/components/Toolbar/TableToolbar.js +45 -65
- package/dist/modules/editor/hooks/index.d.ts +0 -1
- package/dist/modules/editor/hooks/useCommentEditor.d.ts +1 -1
- package/dist/modules/editor/hooks/useCommentEditor.js +4 -12
- package/dist/modules/editor/hooks/useLinkToolbar.d.ts +2 -2
- package/dist/modules/editor/hooks/useLinkToolbar.js +1 -2
- package/dist/modules/editor/hooks/useTipTapEditor.d.ts +3 -3
- package/dist/modules/editor/hooks/useTipTapEditor.js +24 -81
- package/dist/modules/modals/ResourceModal/ResourceModal.js +3 -3
- package/dist/modules/modals/ResourceModal/apps/BlogPublic.js +9 -13
- package/dist/modules/multimedia/Linker/InternalLinker/InternalLinker.d.ts +1 -7
- package/dist/modules/multimedia/Linker/InternalLinker/InternalLinker.js +0 -2
- package/dist/modules/multimedia/MediaLibrary/MediaLibrary.d.ts +0 -2
- package/dist/modules/multimedia/MediaLibrary/MediaLibrary.js +0 -2
- package/dist/modules/multimedia/MediaLibrary/MediaLibraryContext.d.ts +0 -4
- package/dist/modules/multimedia/MediaLibrary/innertabs/Upload.js +1 -2
- package/dist/modules/multimedia/MediaLibrary/innertabs/Workspace.js +0 -3
- package/package.json +43 -35
- package/dist/modules/editor/components/Toolbar/FloatingMenuOptions.d.ts +0 -29
- package/dist/modules/editor/components/Toolbar/FloatingMenuOptions.js +0 -22
- package/dist/modules/editor/hooks/useEditorState.d.ts +0 -20
- package/dist/modules/editor/hooks/useEditorState.js +0 -16
- package/dist/node_modules/.pnpm/@tiptap_extension-floating-menu@3.32.0_@floating-ui_dom@1.6.0_@tiptap_core@3.32.0_@tiptap_pm@3.32.0__@tiptap_pm@3.32.0/node_modules/@tiptap/extension-floating-menu/dist/index.js +0 -159
- package/dist/node_modules/.pnpm/@tiptap_react@3.32.0_@floating-ui_dom@1.6.0_@tiptap_core@3.32.0_@tiptap_pm@3.32.0__@tiptap_pm_6inmb43gajy4fnlwtngbwkv7um/node_modules/@tiptap/react/dist/menus/index.js +0 -341
- package/dist/node_modules/.pnpm/prosemirror-model@1.25.12/node_modules/prosemirror-model/dist/index.js +0 -549
- package/dist/node_modules/.pnpm/prosemirror-state@1.4.4/node_modules/prosemirror-state/dist/index.js +0 -489
- package/dist/node_modules/.pnpm/prosemirror-transform@1.12.3/node_modules/prosemirror-transform/dist/index.js +0 -659
|
@@ -36,7 +36,6 @@ const acceptedTypes = (type) => {
|
|
|
36
36
|
t
|
|
37
37
|
} = useTranslation(), {
|
|
38
38
|
type,
|
|
39
|
-
pdfOnly,
|
|
40
39
|
visibility,
|
|
41
40
|
multiple,
|
|
42
41
|
setResult,
|
|
@@ -61,7 +60,7 @@ const acceptedTypes = (type) => {
|
|
|
61
60
|
/* @__PURE__ */ jsx(Radio, { label: t("bbm.upload.sort.alpha"), name: "media-library-upload-sort", value: "alpha", model: sortByAlpha ? "alpha" : "date", checked: sortByAlpha, onChange: () => setSortByAlpha(!0), "data-testid": "media-library-upload-sort-alpha" }),
|
|
62
61
|
/* @__PURE__ */ jsx(Radio, { label: t("bbm.upload.sort.date"), name: "media-library-upload-sort", value: "date", model: sortByAlpha ? "alpha" : "date", checked: !sortByAlpha, onChange: () => setSortByAlpha(!1), "data-testid": "media-library-upload-sort-date" })
|
|
63
62
|
] }),
|
|
64
|
-
/* @__PURE__ */ jsx(Dropzone, { multiple, accept:
|
|
63
|
+
/* @__PURE__ */ jsx(Dropzone, { multiple, accept: acceptedTypes(type ?? "embedder"), children: /* @__PURE__ */ jsx(UploadFiles, { onFilesChange: handleOnFilesChange, visibility }) })
|
|
65
64
|
] });
|
|
66
65
|
};
|
|
67
66
|
export {
|
|
@@ -4,7 +4,6 @@ import Workspace$1 from "../../Workspace/Workspace.js";
|
|
|
4
4
|
const Workspace = () => {
|
|
5
5
|
const {
|
|
6
6
|
type,
|
|
7
|
-
pdfOnly,
|
|
8
7
|
setResultCounter,
|
|
9
8
|
setResult,
|
|
10
9
|
multiple,
|
|
@@ -18,8 +17,6 @@ const Workspace = () => {
|
|
|
18
17
|
return "audio";
|
|
19
18
|
case "video":
|
|
20
19
|
return "video";
|
|
21
|
-
case "attachment":
|
|
22
|
-
return pdfOnly ? "pdf" : null;
|
|
23
20
|
default:
|
|
24
21
|
return null;
|
|
25
22
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@edifice.io/react",
|
|
3
|
-
"version": "2.6.10-develop
|
|
3
|
+
"version": "2.6.10-develop.20261023111140",
|
|
4
4
|
"description": "Edifice React Library",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -81,39 +81,47 @@
|
|
|
81
81
|
"@dnd-kit/core": "6.3.1",
|
|
82
82
|
"@dnd-kit/sortable": "8.0.0",
|
|
83
83
|
"@dnd-kit/utilities": "3.2.2",
|
|
84
|
-
"@floating-ui/dom": "1.6.0",
|
|
85
84
|
"@floating-ui/react": "0.26.0",
|
|
86
85
|
"@popperjs/core": "2.11.8",
|
|
87
86
|
"@screeb/sdk-browser": "0.5.0",
|
|
88
87
|
"@screeb/sdk-react": "0.6.0",
|
|
89
|
-
"@tiptap/core": "
|
|
90
|
-
"@tiptap/extension-blockquote": "
|
|
91
|
-
"@tiptap/extension-
|
|
92
|
-
"@tiptap/extension-
|
|
93
|
-
"@tiptap/extension-
|
|
94
|
-
"@tiptap/extension-
|
|
95
|
-
"@tiptap/extension-
|
|
96
|
-
"@tiptap/extension-
|
|
97
|
-
"@tiptap/extension-
|
|
98
|
-
"@tiptap/extension-
|
|
99
|
-
"@tiptap/extension-
|
|
100
|
-
"@tiptap/extension-
|
|
101
|
-
"@tiptap/extension-
|
|
102
|
-
"@tiptap/extension-
|
|
103
|
-
"@tiptap/extension-
|
|
104
|
-
"@tiptap/extension-
|
|
105
|
-
"@tiptap/extension-
|
|
106
|
-
"@tiptap/extension-
|
|
107
|
-
"@tiptap/extension-
|
|
108
|
-
"@tiptap/extension-
|
|
109
|
-
"@tiptap/extension-
|
|
110
|
-
"@tiptap/extension-
|
|
111
|
-
"@tiptap/extension-
|
|
112
|
-
"@tiptap/extension-
|
|
113
|
-
"@tiptap/
|
|
114
|
-
"@tiptap/
|
|
115
|
-
"@tiptap/
|
|
116
|
-
"@tiptap/
|
|
88
|
+
"@tiptap/core": "2.11.0",
|
|
89
|
+
"@tiptap/extension-blockquote": "2.11.0",
|
|
90
|
+
"@tiptap/extension-bullet-list": "2.11.0",
|
|
91
|
+
"@tiptap/extension-character-count": "2.11.0",
|
|
92
|
+
"@tiptap/extension-code": "2.11.0",
|
|
93
|
+
"@tiptap/extension-code-block": "2.11.0",
|
|
94
|
+
"@tiptap/extension-color": "2.11.0",
|
|
95
|
+
"@tiptap/extension-dropcursor": "2.11.0",
|
|
96
|
+
"@tiptap/extension-focus": "2.11.0",
|
|
97
|
+
"@tiptap/extension-font-family": "2.11.0",
|
|
98
|
+
"@tiptap/extension-gapcursor": "2.11.0",
|
|
99
|
+
"@tiptap/extension-hard-break": "2.11.0",
|
|
100
|
+
"@tiptap/extension-heading": "2.11.0",
|
|
101
|
+
"@tiptap/extension-highlight": "2.11.0",
|
|
102
|
+
"@tiptap/extension-history": "2.11.0",
|
|
103
|
+
"@tiptap/extension-horizontal-rule": "2.11.0",
|
|
104
|
+
"@tiptap/extension-image": "2.11.0",
|
|
105
|
+
"@tiptap/extension-italic": "2.11.0",
|
|
106
|
+
"@tiptap/extension-link": "2.11.0",
|
|
107
|
+
"@tiptap/extension-list-item": "2.11.0",
|
|
108
|
+
"@tiptap/extension-mathematics": "2.22.0",
|
|
109
|
+
"@tiptap/extension-ordered-list": "2.11.0",
|
|
110
|
+
"@tiptap/extension-placeholder": "2.11.0",
|
|
111
|
+
"@tiptap/extension-strike": "2.11.0",
|
|
112
|
+
"@tiptap/extension-subscript": "2.11.0",
|
|
113
|
+
"@tiptap/extension-superscript": "2.11.0",
|
|
114
|
+
"@tiptap/extension-table": "2.11.0",
|
|
115
|
+
"@tiptap/extension-table-cell": "2.11.0",
|
|
116
|
+
"@tiptap/extension-table-header": "2.11.0",
|
|
117
|
+
"@tiptap/extension-table-row": "2.11.0",
|
|
118
|
+
"@tiptap/extension-text-align": "2.11.0",
|
|
119
|
+
"@tiptap/extension-text-style": "2.11.0",
|
|
120
|
+
"@tiptap/extension-typography": "2.11.0",
|
|
121
|
+
"@tiptap/extension-underline": "2.11.0",
|
|
122
|
+
"@tiptap/pm": "2.11.0",
|
|
123
|
+
"@tiptap/react": "2.11.0",
|
|
124
|
+
"@tiptap/starter-kit": "2.11.0",
|
|
117
125
|
"@uidotdev/usehooks": "2.4.1",
|
|
118
126
|
"antd": "5.29.1",
|
|
119
127
|
"clsx": "2.1.1",
|
|
@@ -132,9 +140,9 @@
|
|
|
132
140
|
"swiper": "10.1.0",
|
|
133
141
|
"ua-parser-js": "1.0.36",
|
|
134
142
|
"zustand": "4.5.7",
|
|
135
|
-
"@edifice.io/
|
|
136
|
-
"@edifice.io/
|
|
137
|
-
"@edifice.io/utilities": "2.6.10-develop
|
|
143
|
+
"@edifice.io/bootstrap": "2.6.10-develop.20261023111140",
|
|
144
|
+
"@edifice.io/tiptap-extensions": "2.6.10-develop.20261023111140",
|
|
145
|
+
"@edifice.io/utilities": "2.6.10-develop.20261023111140"
|
|
138
146
|
},
|
|
139
147
|
"devDependencies": {
|
|
140
148
|
"@babel/plugin-transform-react-pure-annotations": "7.27.1",
|
|
@@ -165,8 +173,8 @@
|
|
|
165
173
|
"vite": "5.4.14",
|
|
166
174
|
"vite-plugin-dts": "4.5.4",
|
|
167
175
|
"vite-tsconfig-paths": "5.1.4",
|
|
168
|
-
"@edifice.io/client": "2.6.10-develop
|
|
169
|
-
"@edifice.io/config": "2.6.10-develop
|
|
176
|
+
"@edifice.io/client": "2.6.10-develop.20261023111140",
|
|
177
|
+
"@edifice.io/config": "2.6.10-develop.20261023111140"
|
|
170
178
|
},
|
|
171
179
|
"peerDependencies": {
|
|
172
180
|
"@react-spring/web": "9.7.5",
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { Placement, VirtualElement } from '@floating-ui/dom';
|
|
2
|
-
export declare const FLOATING_MENU_Z_INDEX = 999;
|
|
3
|
-
/**
|
|
4
|
-
* Builds the `options` prop shared by every BubbleMenu/FloatingMenu in the
|
|
5
|
-
* editor toolbar - only `placement` and `offset` vary from one menu to the
|
|
6
|
-
* next.
|
|
7
|
-
*/
|
|
8
|
-
export declare function getFloatingMenuOptions({ placement, offset, }: {
|
|
9
|
-
placement: Placement;
|
|
10
|
-
offset: {
|
|
11
|
-
mainAxis: number;
|
|
12
|
-
crossAxis: number;
|
|
13
|
-
};
|
|
14
|
-
}): {
|
|
15
|
-
placement: Placement;
|
|
16
|
-
offset: {
|
|
17
|
-
mainAxis: number;
|
|
18
|
-
crossAxis: number;
|
|
19
|
-
};
|
|
20
|
-
strategy: "absolute";
|
|
21
|
-
};
|
|
22
|
-
/**
|
|
23
|
-
* Wraps an already-memoized virtual element in a stable
|
|
24
|
-
* `getReferencedVirtualElement` callback. v3's BubbleMenu re-runs a
|
|
25
|
-
* `dispatch` effect whenever this prop's identity changes; combined with
|
|
26
|
-
* `useEditorState` (which re-renders on every transaction), an inline
|
|
27
|
-
* `() => reference` here causes an infinite render loop.
|
|
28
|
-
*/
|
|
29
|
-
export declare function useReferencedVirtualElement(reference: VirtualElement): () => VirtualElement;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { useCallback } from "react";
|
|
2
|
-
const FLOATING_MENU_Z_INDEX = 999;
|
|
3
|
-
function getFloatingMenuOptions({
|
|
4
|
-
placement,
|
|
5
|
-
offset
|
|
6
|
-
}) {
|
|
7
|
-
return {
|
|
8
|
-
placement,
|
|
9
|
-
// tiptap builds its middleware array from named fields only - a raw
|
|
10
|
-
// `middleware: [offset(...)]` key is silently ignored.
|
|
11
|
-
offset,
|
|
12
|
-
strategy: "absolute"
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
function useReferencedVirtualElement(reference) {
|
|
16
|
-
return useCallback(() => reference, [reference]);
|
|
17
|
-
}
|
|
18
|
-
export {
|
|
19
|
-
FLOATING_MENU_Z_INDEX,
|
|
20
|
-
getFloatingMenuOptions,
|
|
21
|
-
useReferencedVirtualElement
|
|
22
|
-
};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { Editor } from '@tiptap/react';
|
|
2
|
-
/**
|
|
3
|
-
* Hook to track editor state changes in Tiptap v3.
|
|
4
|
-
* Replaces the pattern of using `editor?.state` in useEffect dependencies.
|
|
5
|
-
*
|
|
6
|
-
* @param editor - The Tiptap editor instance
|
|
7
|
-
* @returns A counter that increments on each editor update
|
|
8
|
-
*
|
|
9
|
-
* @example
|
|
10
|
-
* ```tsx
|
|
11
|
-
* const { editor } = useEditorContext();
|
|
12
|
-
* const editorState = useEditorState(editor);
|
|
13
|
-
*
|
|
14
|
-
* useEffect(() => {
|
|
15
|
-
* const attrs = editor?.getAttributes('textStyle');
|
|
16
|
-
* // ... do something with attrs
|
|
17
|
-
* }, [editor, editorState]);
|
|
18
|
-
* ```
|
|
19
|
-
*/
|
|
20
|
-
export declare const useEditorState: (editor: Editor | null | undefined) => number;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { useState, useEffect } from "react";
|
|
2
|
-
const useEditorState = (editor) => {
|
|
3
|
-
const [updateCount, setUpdateCount] = useState(0);
|
|
4
|
-
return useEffect(() => {
|
|
5
|
-
if (!editor) return;
|
|
6
|
-
const handleUpdate = () => {
|
|
7
|
-
setUpdateCount((prev) => prev + 1);
|
|
8
|
-
};
|
|
9
|
-
return editor.on("transaction", handleUpdate), () => {
|
|
10
|
-
editor.off("transaction", handleUpdate);
|
|
11
|
-
};
|
|
12
|
-
}, [editor]), updateCount;
|
|
13
|
-
};
|
|
14
|
-
export {
|
|
15
|
-
useEditorState
|
|
16
|
-
};
|
|
@@ -1,159 +0,0 @@
|
|
|
1
|
-
import { getText, getTextSerializersFromSchema, posToDOMRect, Extension } from "@tiptap/core";
|
|
2
|
-
import { flip, shift, offset, arrow, size, autoPlacement, hide, inline, computePosition } from "@floating-ui/dom";
|
|
3
|
-
import { Plugin, PluginKey } from "../../../../../prosemirror-state@1.4.4/node_modules/prosemirror-state/dist/index.js";
|
|
4
|
-
var FloatingMenuView = class {
|
|
5
|
-
getTextContent(node) {
|
|
6
|
-
return getText(node, { textSerializers: getTextSerializersFromSchema(this.editor.schema) });
|
|
7
|
-
}
|
|
8
|
-
get middlewares() {
|
|
9
|
-
const middlewares = [];
|
|
10
|
-
return this.floatingUIOptions.flip && middlewares.push(flip(typeof this.floatingUIOptions.flip != "boolean" ? this.floatingUIOptions.flip : void 0)), this.floatingUIOptions.shift && middlewares.push(shift(typeof this.floatingUIOptions.shift != "boolean" ? this.floatingUIOptions.shift : void 0)), this.floatingUIOptions.offset && middlewares.push(offset(typeof this.floatingUIOptions.offset != "boolean" ? this.floatingUIOptions.offset : void 0)), this.floatingUIOptions.arrow && middlewares.push(arrow(this.floatingUIOptions.arrow)), this.floatingUIOptions.size && middlewares.push(size(typeof this.floatingUIOptions.size != "boolean" ? this.floatingUIOptions.size : void 0)), this.floatingUIOptions.autoPlacement && middlewares.push(autoPlacement(typeof this.floatingUIOptions.autoPlacement != "boolean" ? this.floatingUIOptions.autoPlacement : void 0)), this.floatingUIOptions.hide && middlewares.push(hide(typeof this.floatingUIOptions.hide != "boolean" ? this.floatingUIOptions.hide : void 0)), this.floatingUIOptions.inline && middlewares.push(inline(typeof this.floatingUIOptions.inline != "boolean" ? this.floatingUIOptions.inline : void 0)), middlewares;
|
|
11
|
-
}
|
|
12
|
-
constructor({ editor, element, view, pluginKey = "floatingMenu", updateDelay = 250, resizeDelay = 60, options, appendTo, shouldShow }) {
|
|
13
|
-
var _options$scrollTarget;
|
|
14
|
-
this.preventHide = !1, this.isVisible = !1, this.scrollTarget = window, this.shouldShow = ({ view: view2, state }) => {
|
|
15
|
-
const { selection } = state, { $anchor, empty } = selection, isRootDepth = $anchor.depth === 1, isEmptyTextBlock = $anchor.parent.isTextblock && !$anchor.parent.type.spec.code && !$anchor.parent.textContent && $anchor.parent.childCount === 0 && !this.getTextContent($anchor.parent);
|
|
16
|
-
return !(!view2.hasFocus() || !empty || !isRootDepth || !isEmptyTextBlock || !this.editor.isEditable);
|
|
17
|
-
}, this.floatingUIOptions = {
|
|
18
|
-
strategy: "absolute",
|
|
19
|
-
placement: "right",
|
|
20
|
-
offset: 8,
|
|
21
|
-
flip: {},
|
|
22
|
-
shift: {},
|
|
23
|
-
arrow: !1,
|
|
24
|
-
size: !1,
|
|
25
|
-
autoPlacement: !1,
|
|
26
|
-
hide: !1,
|
|
27
|
-
inline: !1
|
|
28
|
-
}, this.updateHandler = (view2, selectionChanged, docChanged, oldState) => {
|
|
29
|
-
const { composing } = view2;
|
|
30
|
-
if (!(composing || !selectionChanged && !docChanged)) {
|
|
31
|
-
if (!this.getShouldShow(oldState)) {
|
|
32
|
-
this.hide();
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
this.updatePosition(), this.show();
|
|
36
|
-
}
|
|
37
|
-
}, this.mousedownHandler = () => {
|
|
38
|
-
this.preventHide = !0;
|
|
39
|
-
}, this.focusHandler = () => {
|
|
40
|
-
setTimeout(() => this.update(this.editor.view));
|
|
41
|
-
}, this.blurHandler = ({ event }) => {
|
|
42
|
-
var _this$element$parentN;
|
|
43
|
-
if (this.preventHide) {
|
|
44
|
-
this.preventHide = !1;
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
47
|
-
event != null && event.relatedTarget && (!((_this$element$parentN = this.element.parentNode) === null || _this$element$parentN === void 0) && _this$element$parentN.contains(event.relatedTarget)) || (event == null ? void 0 : event.relatedTarget) !== this.editor.view.dom && this.hide();
|
|
48
|
-
}, this.transactionHandler = ({ transaction: tr }) => {
|
|
49
|
-
const meta = tr.getMeta(this.pluginKey);
|
|
50
|
-
meta === "updatePosition" ? this.updatePosition() : meta && typeof meta == "object" && meta.type === "updateOptions" ? this.updateOptions(meta.options) : meta === "hide" ? this.hide() : meta === "show" && (this.updatePosition(), this.show());
|
|
51
|
-
}, this.resizeHandler = () => {
|
|
52
|
-
this.resizeDebounceTimer && clearTimeout(this.resizeDebounceTimer), this.resizeDebounceTimer = window.setTimeout(() => {
|
|
53
|
-
this.updatePosition();
|
|
54
|
-
}, this.resizeDelay);
|
|
55
|
-
}, this.editor = editor, this.element = element, this.view = view, this.pluginKey = pluginKey, this.updateDelay = updateDelay, this.resizeDelay = resizeDelay, this.appendTo = appendTo, this.scrollTarget = (_options$scrollTarget = options == null ? void 0 : options.scrollTarget) !== null && _options$scrollTarget !== void 0 ? _options$scrollTarget : window, this.floatingUIOptions = {
|
|
56
|
-
...this.floatingUIOptions,
|
|
57
|
-
...options
|
|
58
|
-
}, this.element.tabIndex = 0, shouldShow && (this.shouldShow = shouldShow), this.element.addEventListener("mousedown", this.mousedownHandler, { capture: !0 }), this.editor.on("focus", this.focusHandler), this.editor.on("blur", this.blurHandler), this.editor.on("transaction", this.transactionHandler), window.addEventListener("resize", this.resizeHandler), this.scrollTarget.addEventListener("scroll", this.resizeHandler), this.update(view, view.state), this.getShouldShow() && (this.show(), this.updatePosition());
|
|
59
|
-
}
|
|
60
|
-
getShouldShow(oldState) {
|
|
61
|
-
var _this$shouldShow;
|
|
62
|
-
const { state } = this.view, { selection } = state, { ranges } = selection, from = Math.min(...ranges.map((range) => range.$from.pos)), to = Math.max(...ranges.map((range) => range.$to.pos));
|
|
63
|
-
return (_this$shouldShow = this.shouldShow) === null || _this$shouldShow === void 0 ? void 0 : _this$shouldShow.call(this, {
|
|
64
|
-
editor: this.editor,
|
|
65
|
-
view: this.view,
|
|
66
|
-
state,
|
|
67
|
-
oldState,
|
|
68
|
-
from,
|
|
69
|
-
to
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
updateOptions(newProps) {
|
|
73
|
-
if (newProps.updateDelay !== void 0 && (this.updateDelay = newProps.updateDelay), newProps.resizeDelay !== void 0 && (this.resizeDelay = newProps.resizeDelay), newProps.appendTo !== void 0 && (this.appendTo = newProps.appendTo), newProps.shouldShow !== void 0 && newProps.shouldShow && (this.shouldShow = newProps.shouldShow), newProps.options !== void 0) {
|
|
74
|
-
var _newProps$options$scr;
|
|
75
|
-
const newScrollTarget = (_newProps$options$scr = newProps.options.scrollTarget) !== null && _newProps$options$scr !== void 0 ? _newProps$options$scr : window;
|
|
76
|
-
newScrollTarget !== this.scrollTarget && (this.scrollTarget.removeEventListener("scroll", this.resizeHandler), this.scrollTarget = newScrollTarget, this.scrollTarget.addEventListener("scroll", this.resizeHandler)), this.floatingUIOptions = {
|
|
77
|
-
...this.floatingUIOptions,
|
|
78
|
-
...newProps.options
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
updatePosition() {
|
|
83
|
-
var _this$view;
|
|
84
|
-
if (!(!((_this$view = this.view) === null || _this$view === void 0 || (_this$view = _this$view.dom) === null || _this$view === void 0) && _this$view.parentNode)) return;
|
|
85
|
-
const { selection } = this.editor.state, domRect = posToDOMRect(this.view, selection.from, selection.to);
|
|
86
|
-
computePosition({
|
|
87
|
-
getBoundingClientRect: () => domRect,
|
|
88
|
-
getClientRects: () => [domRect]
|
|
89
|
-
}, this.element, {
|
|
90
|
-
placement: this.floatingUIOptions.placement,
|
|
91
|
-
strategy: this.floatingUIOptions.strategy,
|
|
92
|
-
middleware: this.middlewares
|
|
93
|
-
}).then(({ x, y, strategy, middlewareData }) => {
|
|
94
|
-
var _middlewareData$hide, _middlewareData$hide2;
|
|
95
|
-
if (!((_middlewareData$hide = middlewareData.hide) === null || _middlewareData$hide === void 0) && _middlewareData$hide.referenceHidden || !((_middlewareData$hide2 = middlewareData.hide) === null || _middlewareData$hide2 === void 0) && _middlewareData$hide2.escaped) {
|
|
96
|
-
this.element.style.visibility = "hidden";
|
|
97
|
-
return;
|
|
98
|
-
}
|
|
99
|
-
this.element.style.visibility = "visible", this.element.style.width = "max-content", this.element.style.position = strategy, this.element.style.left = `${x}px`, this.element.style.top = `${y}px`, this.isVisible && this.floatingUIOptions.onUpdate && this.floatingUIOptions.onUpdate();
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
update(view, oldState) {
|
|
103
|
-
const selectionChanged = !(oldState != null && oldState.selection.eq(view.state.selection)), docChanged = !(oldState != null && oldState.doc.eq(view.state.doc));
|
|
104
|
-
this.updateHandler(view, selectionChanged, docChanged, oldState);
|
|
105
|
-
}
|
|
106
|
-
show() {
|
|
107
|
-
var _ref;
|
|
108
|
-
if (this.isVisible) return;
|
|
109
|
-
this.element.style.visibility = "visible", this.element.style.opacity = "1";
|
|
110
|
-
const appendToElement = typeof this.appendTo == "function" ? this.appendTo() : this.appendTo;
|
|
111
|
-
(_ref = appendToElement ?? this.view.dom.parentElement) === null || _ref === void 0 || _ref.appendChild(this.element), this.floatingUIOptions.onShow && this.floatingUIOptions.onShow(), this.isVisible = !0;
|
|
112
|
-
}
|
|
113
|
-
hide() {
|
|
114
|
-
this.isVisible && (this.element.style.visibility = "hidden", this.element.style.opacity = "0", this.element.remove(), this.floatingUIOptions.onHide && this.floatingUIOptions.onHide(), this.isVisible = !1);
|
|
115
|
-
}
|
|
116
|
-
destroy() {
|
|
117
|
-
this.hide(), this.element.removeEventListener("mousedown", this.mousedownHandler, { capture: !0 }), window.removeEventListener("resize", this.resizeHandler), this.scrollTarget.removeEventListener("scroll", this.resizeHandler), this.editor.off("focus", this.focusHandler), this.editor.off("blur", this.blurHandler), this.editor.off("transaction", this.transactionHandler), this.floatingUIOptions.onDestroy && this.floatingUIOptions.onDestroy();
|
|
118
|
-
}
|
|
119
|
-
};
|
|
120
|
-
const FloatingMenuPlugin = (options) => new Plugin({
|
|
121
|
-
key: typeof options.pluginKey == "string" ? new PluginKey(options.pluginKey) : options.pluginKey,
|
|
122
|
-
view: (view) => new FloatingMenuView({
|
|
123
|
-
view,
|
|
124
|
-
...options
|
|
125
|
-
})
|
|
126
|
-
});
|
|
127
|
-
Extension.create({
|
|
128
|
-
name: "floatingMenu",
|
|
129
|
-
addOptions() {
|
|
130
|
-
return {
|
|
131
|
-
element: null,
|
|
132
|
-
options: {},
|
|
133
|
-
pluginKey: "floatingMenu",
|
|
134
|
-
updateDelay: void 0,
|
|
135
|
-
resizeDelay: void 0,
|
|
136
|
-
appendTo: void 0,
|
|
137
|
-
shouldShow: null
|
|
138
|
-
};
|
|
139
|
-
},
|
|
140
|
-
addCommands() {
|
|
141
|
-
return { updateFloatingMenuPosition: () => ({ tr, dispatch }) => (dispatch && tr.setMeta(this.options.pluginKey, "updatePosition"), !0) };
|
|
142
|
-
},
|
|
143
|
-
addProseMirrorPlugins() {
|
|
144
|
-
return this.options.element ? [FloatingMenuPlugin({
|
|
145
|
-
pluginKey: this.options.pluginKey,
|
|
146
|
-
editor: this.editor,
|
|
147
|
-
element: this.options.element,
|
|
148
|
-
updateDelay: this.options.updateDelay,
|
|
149
|
-
resizeDelay: this.options.resizeDelay,
|
|
150
|
-
options: this.options.options,
|
|
151
|
-
appendTo: this.options.appendTo,
|
|
152
|
-
shouldShow: this.options.shouldShow
|
|
153
|
-
})] : [];
|
|
154
|
-
}
|
|
155
|
-
});
|
|
156
|
-
export {
|
|
157
|
-
FloatingMenuPlugin,
|
|
158
|
-
FloatingMenuView
|
|
159
|
-
};
|