@edifice.io/react 2.6.10-develop-integration.20261021201242 → 2.6.10-develop-pedago.20261022103835
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 +2 -0
- package/dist/hooks/index.d.ts +0 -1
- package/dist/icons-apps.js +182 -184
- package/dist/index.js +192 -198
- package/dist/modules/editor/components/BubbleMenuEditImage/BubbleMenuEditImage.js +110 -91
- package/dist/modules/editor/components/BubbleMenuEditInformationPane/BubbleMenuEditInformationPane.js +123 -96
- package/dist/modules/editor/components/EditorToolbar/EditorToolbar.HighlightColor.js +5 -8
- package/dist/modules/editor/components/EditorToolbar/EditorToolbar.TextColor.js +5 -8
- package/dist/modules/editor/components/EditorToolbar/EditorToolbar.Typography.js +3 -2
- package/dist/modules/editor/components/EditorToolbar/EditorToolbar.js +6 -4
- package/dist/modules/editor/components/Toolbar/FloatingMenuOptions.d.ts +29 -0
- package/dist/modules/editor/components/Toolbar/FloatingMenuOptions.js +22 -0
- package/dist/modules/editor/components/Toolbar/LinkToolbar.d.ts +6 -3
- package/dist/modules/editor/components/Toolbar/LinkToolbar.js +29 -7
- package/dist/modules/editor/components/Toolbar/TableToolbar.CellColor.js +3 -2
- package/dist/modules/editor/components/Toolbar/TableToolbar.js +65 -45
- package/dist/modules/editor/hooks/index.d.ts +1 -0
- package/dist/modules/editor/hooks/useCommentEditor.d.ts +1 -1
- package/dist/modules/editor/hooks/useCommentEditor.js +12 -4
- package/dist/modules/editor/hooks/useEditorState.d.ts +20 -0
- package/dist/modules/editor/hooks/useEditorState.js +16 -0
- package/dist/modules/editor/hooks/useLinkToolbar.d.ts +2 -2
- package/dist/modules/editor/hooks/useLinkToolbar.js +2 -1
- package/dist/modules/editor/hooks/useTipTapEditor.d.ts +3 -3
- package/dist/modules/editor/hooks/useTipTapEditor.js +72 -24
- package/dist/modules/homepage/components/Notifications/components/CommonNotificationItem.js +9 -9
- package/dist/modules/homepage/components/Notifications/components/notificationAdapter.d.ts +1 -2
- package/dist/modules/homepage/components/Notifications/components/notificationAdapter.js +2 -2
- package/dist/modules/icons/components/apps/index.d.ts +0 -1
- package/dist/modules/multimedia/FileCard/index.d.ts +0 -2
- 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 +2 -0
- package/dist/modules/multimedia/MediaLibrary/MediaLibrary.js +7 -16
- package/dist/modules/multimedia/MediaLibrary/MediaLibraryContext.d.ts +4 -0
- package/dist/modules/multimedia/MediaLibrary/innertabs/Upload.js +2 -1
- package/dist/modules/multimedia/MediaLibrary/innertabs/Workspace.js +3 -0
- package/dist/modules/multimedia/MediaLibrary/innertabs/index.d.ts +0 -1
- package/dist/modules/multimedia/MediaLibrary/innertabs/index.js +0 -2
- package/dist/modules/multimedia/index.d.ts +0 -1
- package/dist/multimedia.js +22 -26
- 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 +159 -0
- 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 +341 -0
- package/dist/node_modules/.pnpm/prosemirror-model@1.25.12/node_modules/prosemirror-model/dist/index.js +419 -0
- package/dist/node_modules/.pnpm/prosemirror-state@1.4.4/node_modules/prosemirror-state/dist/index.js +489 -0
- package/dist/node_modules/.pnpm/prosemirror-transform@1.12.2/node_modules/prosemirror-transform/dist/index.js +607 -0
- package/package.json +35 -43
- package/dist/hooks/useGoogleDriveSearch/index.d.ts +0 -1
- package/dist/hooks/useGoogleDriveSearch/useGoogleDriveSearch.d.ts +0 -19
- package/dist/hooks/useGoogleDriveSearch/useGoogleDriveSearch.js +0 -60
- package/dist/modules/editor/components/Toolbar/LinkToolbar.TippyOptions.d.ts +0 -2
- package/dist/modules/editor/components/Toolbar/LinkToolbar.TippyOptions.js +0 -8
- package/dist/modules/icons/components/apps/IconElea.d.ts +0 -7
- package/dist/modules/icons/components/apps/IconElea.js +0 -23
- package/dist/modules/multimedia/FileCard/GoogleDriveFileCard.d.ts +0 -25
- package/dist/modules/multimedia/FileCard/GoogleDriveFileCard.js +0 -102
- package/dist/modules/multimedia/GoogleDrive/GoogleDrive.d.ts +0 -24
- package/dist/modules/multimedia/GoogleDrive/GoogleDrive.js +0 -103
- package/dist/modules/multimedia/GoogleDrive/index.d.ts +0 -2
- package/dist/modules/multimedia/MediaLibrary/innertabs/GoogleDrive.d.ts +0 -1
- package/dist/modules/multimedia/MediaLibrary/innertabs/GoogleDrive.js +0 -61
|
@@ -23,7 +23,6 @@ const InternalLinker = ({
|
|
|
23
23
|
resourceList,
|
|
24
24
|
applicationList,
|
|
25
25
|
showApplicationSelector = !0,
|
|
26
|
-
searchFilter,
|
|
27
26
|
disableApplicationSelector = !1,
|
|
28
27
|
resourceFilter,
|
|
29
28
|
onSearch,
|
|
@@ -132,7 +131,6 @@ const InternalLinker = ({
|
|
|
132
131
|
] }), variant: "ghost", size: "md", disabled: disableApplicationSelector }),
|
|
133
132
|
/* @__PURE__ */ jsx(Dropdown.Menu, { children: options == null ? void 0 : options.map((option) => /* @__PURE__ */ jsx(Dropdown.Item, { icon: option.icon, onClick: () => handleOptionClick(option), children: option.displayName }, option.application)) })
|
|
134
133
|
] }) }),
|
|
135
|
-
!showApplicationSelector && searchFilter && /* @__PURE__ */ jsx("div", { className: "flex-shrink-1 px-8 py-12 border-end align-self-center", children: searchFilter }),
|
|
136
134
|
/* @__PURE__ */ jsx("div", { className: "flex-grow-1 align-self-center", children: /* @__PURE__ */ jsx("form", { className: "gap-16 d-flex w-100 align-items-center px-16 py-8", onSubmit: handleSubmit, children: /* @__PURE__ */ jsx(SearchBar, { isVariant: !0, placeholder: t("search"), size: "lg", className: "w-100", disabled: !selectedApplication, onChange: handleSearchChange }) }) })
|
|
137
135
|
] }),
|
|
138
136
|
/* @__PURE__ */ jsxs("div", { className: "internal-linker flex-grow-1 w-100 rounded-bottom border gap-0 overflow-auto", children: [
|
|
@@ -65,6 +65,8 @@ export interface MediaLibraryProps {
|
|
|
65
65
|
visibility: WorkspaceVisibility;
|
|
66
66
|
/** Allow selecting / uploading multiple files at once ? */
|
|
67
67
|
multiple?: boolean;
|
|
68
|
+
/** Restrict attachments to PDF files in Workspace and Upload. */
|
|
69
|
+
pdfOnly?: boolean;
|
|
68
70
|
/**
|
|
69
71
|
* Called when the user validates the modal (Add button).
|
|
70
72
|
* @param result depends on which InnerTab is visible
|
|
@@ -33,11 +33,9 @@ const orderedTabs = [
|
|
|
33
33
|
// Media browser
|
|
34
34
|
"nextcloud",
|
|
35
35
|
// Nextcloud media browser
|
|
36
|
-
"google-drive",
|
|
37
|
-
// Google Drive media browser
|
|
38
36
|
"video-embedder"
|
|
39
37
|
// Link to a hosted video
|
|
40
|
-
],
|
|
38
|
+
], mediaLibraryTypes = {
|
|
41
39
|
none: null,
|
|
42
40
|
audio: {
|
|
43
41
|
title: "bbm.audio.modal.title",
|
|
@@ -72,11 +70,12 @@ const orderedTabs = [
|
|
|
72
70
|
appCode,
|
|
73
71
|
visibility,
|
|
74
72
|
multiple,
|
|
73
|
+
pdfOnly,
|
|
75
74
|
onSuccess,
|
|
76
75
|
onCancel,
|
|
77
76
|
onTabChange
|
|
78
77
|
}, ref) => {
|
|
79
|
-
var _a, _b
|
|
78
|
+
var _a, _b;
|
|
80
79
|
const linkTabProps = useRef(), refModal = useRef(null);
|
|
81
80
|
useImperativeHandle(ref, () => ({
|
|
82
81
|
show,
|
|
@@ -87,9 +86,9 @@ const orderedTabs = [
|
|
|
87
86
|
}));
|
|
88
87
|
const {
|
|
89
88
|
t
|
|
90
|
-
} = useTranslation(), workspaceCreateWorkflow = useHasWorkflow("org.entcore.workspace.controllers.WorkspaceController|addDocument"), videoCaptureWorkflow = useHasWorkflow("com.opendigitaleducation.video.controllers.VideoController|capture"), nextcloudViewWorkflow = useHasWorkflow("fr.openent.nextcloud.controller.NextcloudController|view"),
|
|
89
|
+
} = useTranslation(), workspaceCreateWorkflow = useHasWorkflow("org.entcore.workspace.controllers.WorkspaceController|addDocument"), videoCaptureWorkflow = useHasWorkflow("com.opendigitaleducation.video.controllers.VideoController|capture"), nextcloudViewWorkflow = useHasWorkflow("fr.openent.nextcloud.controller.NextcloudController|view"), {
|
|
91
90
|
data: workspacePublicConf
|
|
92
|
-
} = usePublicConf("workspace"), enableNextcloudTab = ((_a = workspacePublicConf == null ? void 0 : workspacePublicConf["folder-service"]) == null ? void 0 : _a.includes("nextcloud")) && nextcloudViewWorkflow,
|
|
91
|
+
} = usePublicConf("workspace"), enableNextcloudTab = ((_a = workspacePublicConf == null ? void 0 : workspacePublicConf["folder-service"]) == null ? void 0 : _a.includes("nextcloud")) && nextcloudViewWorkflow, [type, setType] = useState(null);
|
|
93
92
|
useHttpErrorToast({
|
|
94
93
|
active: !!type,
|
|
95
94
|
isDismissible: !0,
|
|
@@ -112,15 +111,6 @@ const orderedTabs = [
|
|
|
112
111
|
availableFor: ["audio", "video", "image", "attachment"],
|
|
113
112
|
isEnable: () => !!enableNextcloudTab
|
|
114
113
|
},
|
|
115
|
-
"google-drive": {
|
|
116
|
-
id: "google-drive",
|
|
117
|
-
// FIXME No Google Drive icon in the pack yet; reusing the generic one.
|
|
118
|
-
icon: /* @__PURE__ */ jsx(SvgIconGlobe2, {}),
|
|
119
|
-
label: t("bbm.google-drive"),
|
|
120
|
-
content: /* @__PURE__ */ jsx(InnerTabs.GoogleDrive, {}),
|
|
121
|
-
availableFor: ["audio", "video", "image", "attachment"],
|
|
122
|
-
isEnable: () => !!enableGoogleDriveTab
|
|
123
|
-
},
|
|
124
114
|
upload: {
|
|
125
115
|
id: "upload",
|
|
126
116
|
icon: /* @__PURE__ */ jsx(SvgIconSmartphone, {}),
|
|
@@ -206,7 +196,7 @@ const orderedTabs = [
|
|
|
206
196
|
const typeKey = type || "none";
|
|
207
197
|
!defaultTabId && typeof ((_a2 = mediaLibraryTypes[typeKey]) == null ? void 0 : _a2.defaultTab) == "string" && setDefaultTabId((_b2 = mediaLibraryTypes[typeKey]) == null ? void 0 : _b2.defaultTab);
|
|
208
198
|
}, [defaultTabId, type]);
|
|
209
|
-
const modalHeader = t(((
|
|
199
|
+
const modalHeader = t(((_b = mediaLibraryTypes[type ?? "none"]) == null ? void 0 : _b.title) ?? "bbm"), resetState = () => {
|
|
210
200
|
linkTabProps.current = void 0, setResult(void 0), setResultCounter(void 0), setDefaultTabId(void 0), setPreSuccess(void 0), setDeletionsOnCancel([]);
|
|
211
201
|
}, handleTabChange = (tab) => {
|
|
212
202
|
onTabChange == null || onTabChange(tab, deletionsOnCancel), resetState();
|
|
@@ -235,6 +225,7 @@ const orderedTabs = [
|
|
|
235
225
|
appCode,
|
|
236
226
|
visibility,
|
|
237
227
|
multiple,
|
|
228
|
+
pdfOnly,
|
|
238
229
|
type,
|
|
239
230
|
setResultCounter,
|
|
240
231
|
setResult,
|
|
@@ -7,6 +7,8 @@ export declare const MediaLibraryContext: import('react').Context<{
|
|
|
7
7
|
visibility?: WorkspaceVisibility;
|
|
8
8
|
/** Allow selecting / uploading multiple files at once ? */
|
|
9
9
|
multiple?: boolean;
|
|
10
|
+
/** Restrict attachments to PDF files in Workspace and Upload. */
|
|
11
|
+
pdfOnly?: boolean;
|
|
10
12
|
/** Type of resource to search for. */
|
|
11
13
|
type: MediaLibraryType | null;
|
|
12
14
|
/** Set the counter in the success button label. */
|
|
@@ -36,6 +38,8 @@ export declare function useMediaLibraryContext(): {
|
|
|
36
38
|
visibility?: WorkspaceVisibility;
|
|
37
39
|
/** Allow selecting / uploading multiple files at once ? */
|
|
38
40
|
multiple?: boolean;
|
|
41
|
+
/** Restrict attachments to PDF files in Workspace and Upload. */
|
|
42
|
+
pdfOnly?: boolean;
|
|
39
43
|
/** Type of resource to search for. */
|
|
40
44
|
type: MediaLibraryType | null;
|
|
41
45
|
/** Set the counter in the success button label. */
|
|
@@ -36,6 +36,7 @@ const acceptedTypes = (type) => {
|
|
|
36
36
|
t
|
|
37
37
|
} = useTranslation(), {
|
|
38
38
|
type,
|
|
39
|
+
pdfOnly,
|
|
39
40
|
visibility,
|
|
40
41
|
multiple,
|
|
41
42
|
setResult,
|
|
@@ -60,7 +61,7 @@ const acceptedTypes = (type) => {
|
|
|
60
61
|
/* @__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" }),
|
|
61
62
|
/* @__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" })
|
|
62
63
|
] }),
|
|
63
|
-
/* @__PURE__ */ jsx(Dropzone, { multiple, accept: acceptedTypes(type ?? "embedder"), children: /* @__PURE__ */ jsx(UploadFiles, { onFilesChange: handleOnFilesChange, visibility }) })
|
|
64
|
+
/* @__PURE__ */ jsx(Dropzone, { multiple, accept: type === "attachment" && pdfOnly ? ["application/pdf"] : acceptedTypes(type ?? "embedder"), children: /* @__PURE__ */ jsx(UploadFiles, { onFilesChange: handleOnFilesChange, visibility }) })
|
|
64
65
|
] });
|
|
65
66
|
};
|
|
66
67
|
export {
|
|
@@ -4,6 +4,7 @@ import Workspace$1 from "../../Workspace/Workspace.js";
|
|
|
4
4
|
const Workspace = () => {
|
|
5
5
|
const {
|
|
6
6
|
type,
|
|
7
|
+
pdfOnly,
|
|
7
8
|
setResultCounter,
|
|
8
9
|
setResult,
|
|
9
10
|
multiple,
|
|
@@ -17,6 +18,8 @@ const Workspace = () => {
|
|
|
17
18
|
return "audio";
|
|
18
19
|
case "video":
|
|
19
20
|
return "video";
|
|
21
|
+
case "attachment":
|
|
22
|
+
return pdfOnly ? "pdf" : null;
|
|
20
23
|
default:
|
|
21
24
|
return null;
|
|
22
25
|
}
|
|
@@ -5,7 +5,6 @@ export declare const InnerTabs: {
|
|
|
5
5
|
ExternalLink: ({ link, multiNodeSelected, }: import('./ExternalLink').ExternalLinkTabProps) => import("react/jsx-runtime").JSX.Element;
|
|
6
6
|
Workspace: () => import("react/jsx-runtime").JSX.Element;
|
|
7
7
|
Nextcloud: () => import("react/jsx-runtime").JSX.Element;
|
|
8
|
-
GoogleDrive: () => import("react/jsx-runtime").JSX.Element;
|
|
9
8
|
InternalLink: ({ target, resourceId, appPrefix, }: import('./InternalLink').InternalLinkTabProps) => import("react/jsx-runtime").JSX.Element;
|
|
10
9
|
Iframe: () => import("react/jsx-runtime").JSX.Element;
|
|
11
10
|
VideoEmbedder: () => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Audio } from "./Audio.js";
|
|
2
2
|
import { ExternalLink } from "./ExternalLink.js";
|
|
3
|
-
import { GoogleDrive } from "./GoogleDrive.js";
|
|
4
3
|
import { Iframe } from "./Iframe.js";
|
|
5
4
|
import { InternalLink } from "./InternalLink.js";
|
|
6
5
|
import { Nextcloud } from "./Nextcloud.js";
|
|
@@ -15,7 +14,6 @@ const InnerTabs = {
|
|
|
15
14
|
ExternalLink,
|
|
16
15
|
Workspace,
|
|
17
16
|
Nextcloud,
|
|
18
|
-
GoogleDrive,
|
|
19
17
|
InternalLink,
|
|
20
18
|
Iframe,
|
|
21
19
|
VideoEmbedder
|
package/dist/multimedia.js
CHANGED
|
@@ -1,19 +1,17 @@
|
|
|
1
1
|
import { default as default2 } from "./modules/multimedia/AudioRecorder/AudioRecorder.js";
|
|
2
2
|
import { default as default3 } from "./modules/multimedia/Embed/Embed.js";
|
|
3
3
|
import { default as default4 } from "./modules/multimedia/FileCard/FileCard.js";
|
|
4
|
-
import { default as default5 } from "./modules/multimedia/
|
|
5
|
-
import { default as default6 } from "./modules/multimedia/
|
|
6
|
-
import { default as default7 } from "./modules/multimedia/
|
|
7
|
-
import { default as default8 } from "./modules/multimedia/
|
|
8
|
-
import { default as default9 } from "./modules/multimedia/
|
|
9
|
-
import { default as default10 } from "./modules/multimedia/
|
|
10
|
-
import { default as default11 } from "./modules/multimedia/
|
|
11
|
-
import { default as default12 } from "./modules/multimedia/
|
|
12
|
-
import { default as default13 } from "./modules/multimedia/
|
|
13
|
-
import { default as default14 } from "./modules/multimedia/
|
|
14
|
-
import { default as default15 } from "./modules/multimedia/
|
|
15
|
-
import { default as default16 } from "./modules/multimedia/Workspace/Workspace.js";
|
|
16
|
-
import { default as default17 } from "./modules/multimedia/WorkspaceFolders/WorkspaceFolders.js";
|
|
4
|
+
import { default as default5 } from "./modules/multimedia/ImageEditor/components/ImageEditor.js";
|
|
5
|
+
import { default as default6 } from "./modules/multimedia/ImagePicker/ImagePicker.js";
|
|
6
|
+
import { default as default7 } from "./modules/multimedia/MediaLibrary/MediaLibrary.js";
|
|
7
|
+
import { default as default8 } from "./modules/multimedia/Nextcloud/Nextcloud.js";
|
|
8
|
+
import { default as default9 } from "./modules/multimedia/FileCard/NextcloudFileCard.js";
|
|
9
|
+
import { default as default10 } from "./modules/multimedia/UploadCard/UploadCard.js";
|
|
10
|
+
import { default as default11 } from "./modules/multimedia/UploadFiles/UploadFiles.js";
|
|
11
|
+
import { default as default12 } from "./modules/multimedia/VideoEmbed/VideoEmbed.js";
|
|
12
|
+
import { default as default13 } from "./modules/multimedia/VideoRecorder/VideoRecorder.js";
|
|
13
|
+
import { default as default14 } from "./modules/multimedia/Workspace/Workspace.js";
|
|
14
|
+
import { default as default15 } from "./modules/multimedia/WorkspaceFolders/WorkspaceFolders.js";
|
|
17
15
|
import { ExternalLinker } from "./modules/multimedia/Linker/ExternalLinker/ExternalLinker.js";
|
|
18
16
|
import { InternalLinker } from "./modules/multimedia/Linker/InternalLinker/InternalLinker.js";
|
|
19
17
|
import { Upload } from "./modules/multimedia/MediaLibrary/innertabs/Upload.js";
|
|
@@ -22,19 +20,17 @@ export {
|
|
|
22
20
|
default3 as Embed,
|
|
23
21
|
ExternalLinker,
|
|
24
22
|
default4 as FileCard,
|
|
25
|
-
default5 as
|
|
26
|
-
default6 as
|
|
27
|
-
default7 as ImageEditor,
|
|
28
|
-
default8 as ImagePicker,
|
|
23
|
+
default5 as ImageEditor,
|
|
24
|
+
default6 as ImagePicker,
|
|
29
25
|
InternalLinker,
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
26
|
+
default7 as MediaLibrary,
|
|
27
|
+
default8 as Nextcloud,
|
|
28
|
+
default9 as NextcloudFileCard,
|
|
33
29
|
Upload,
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
30
|
+
default10 as UploadCard,
|
|
31
|
+
default11 as UploadFiles,
|
|
32
|
+
default12 as VideoEmbed,
|
|
33
|
+
default13 as VideoRecorder,
|
|
34
|
+
default14 as Workspace,
|
|
35
|
+
default15 as WorkspaceFolders
|
|
40
36
|
};
|
|
@@ -0,0 +1,159 @@
|
|
|
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
|
+
};
|