@edifice.io/react 2.0.5-develop-pedago.20250212100405 → 2.0.5-develop-pedago.20250212101448
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
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { EditorContent, Editor, useEditor } from "@tiptap/react";
|
|
2
2
|
import { default as default2 } from "@tiptap/starter-kit";
|
|
3
|
-
import { default as default3 } from "./modules/editor/components/
|
|
4
|
-
import { default as default4 } from "./modules/editor/components/
|
|
5
|
-
import { default as default5 } from "./modules/editor/components/NodeView/
|
|
6
|
-
import { default as default6 } from "./modules/editor/components/NodeView/
|
|
7
|
-
import { default as default7 } from "./modules/editor/components/NodeView/
|
|
8
|
-
import { default as default8 } from "./modules/editor/components/NodeView/
|
|
9
|
-
import { default as default9 } from "./modules/editor/components/
|
|
10
|
-
import { default as default10 } from "./modules/editor/components/Renderer/
|
|
11
|
-
import { default as default11 } from "./modules/editor/components/Renderer/
|
|
12
|
-
import { default as default12 } from "./modules/editor/components/Renderer/
|
|
13
|
-
import { default as default13 } from "./modules/editor/components/
|
|
14
|
-
import { default as default14 } from "./modules/editor/components/Toolbar/
|
|
3
|
+
import { default as default3 } from "./modules/editor/components/Editor/Editor.js";
|
|
4
|
+
import { default as default4 } from "./modules/editor/components/BubbleMenuEditImage/BubbleMenuEditImage.js";
|
|
5
|
+
import { default as default5 } from "./modules/editor/components/NodeView/AudioNodeView.js";
|
|
6
|
+
import { default as default6 } from "./modules/editor/components/NodeView/AttachmentNodeView.js";
|
|
7
|
+
import { default as default7 } from "./modules/editor/components/NodeView/ImageNodeView.js";
|
|
8
|
+
import { default as default8 } from "./modules/editor/components/NodeView/LinkerNodeView.js";
|
|
9
|
+
import { default as default9 } from "./modules/editor/components/NodeView/VideoNodeView.js";
|
|
10
|
+
import { default as default10 } from "./modules/editor/components/Renderer/AudioRenderer.js";
|
|
11
|
+
import { default as default11 } from "./modules/editor/components/Renderer/AttachmentRenderer.js";
|
|
12
|
+
import { default as default12 } from "./modules/editor/components/Renderer/LinkerRenderer.js";
|
|
13
|
+
import { default as default13 } from "./modules/editor/components/Renderer/MediaRenderer.js";
|
|
14
|
+
import { default as default14 } from "./modules/editor/components/Toolbar/TableToolbar.js";
|
|
15
|
+
import { default as default15 } from "./modules/editor/components/Toolbar/LinkToolbar.js";
|
|
15
16
|
import { EditorToolbar } from "./modules/editor/components/EditorToolbar/EditorToolbar.js";
|
|
16
17
|
import { useActionOptions } from "./modules/editor/hooks/useActionOptions.js";
|
|
17
18
|
import { useCommentEditor } from "./modules/editor/hooks/useCommentEditor.js";
|
|
@@ -26,23 +27,24 @@ import { useSpeechRecognition } from "./modules/editor/hooks/useSpeechRecognitio
|
|
|
26
27
|
import { useSpeechSynthetisis } from "./modules/editor/hooks/useSpeechSynthetisis.js";
|
|
27
28
|
import { useTipTapEditor } from "./modules/editor/hooks/useTipTapEditor.js";
|
|
28
29
|
export {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
Editor,
|
|
30
|
+
default6 as AttachmentNodeView,
|
|
31
|
+
default11 as AttachmentRenderer,
|
|
32
|
+
default5 as AudioNodeView,
|
|
33
|
+
default10 as AudioRenderer,
|
|
34
|
+
default4 as BubbleMenuEditImage,
|
|
35
|
+
default3 as Editor,
|
|
35
36
|
EditorContent,
|
|
36
37
|
EditorContext,
|
|
37
38
|
EditorToolbar,
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
39
|
+
default7 as ImageNodeView,
|
|
40
|
+
default15 as LinkToolbar,
|
|
41
|
+
default8 as LinkerNodeView,
|
|
42
|
+
default12 as LinkerRenderer,
|
|
43
|
+
default13 as MediaRenderer,
|
|
43
44
|
default2 as StarterKit,
|
|
44
|
-
|
|
45
|
-
|
|
45
|
+
default14 as TableToolbar,
|
|
46
|
+
Editor as TipTapEditor,
|
|
47
|
+
default9 as VideoNodeView,
|
|
46
48
|
useActionOptions,
|
|
47
49
|
useCommentEditor,
|
|
48
50
|
useEditor,
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef, useId, useImperativeHandle, Suspense, lazy } from "react";
|
|
3
|
+
import { EditorContent } from "@tiptap/react";
|
|
4
|
+
import clsx from "clsx";
|
|
5
|
+
import "@tiptap/starter-kit";
|
|
6
|
+
import { useEdificeClient } from "../../../../providers/EdificeClientProvider/EdificeClientProvider.hook.js";
|
|
7
|
+
import { useMathsStyles } from "../../hooks/useMathsStyles.js";
|
|
8
|
+
import { useTipTapEditor } from "../../hooks/useTipTapEditor.js";
|
|
9
|
+
import { useMediaLibraryEditor } from "../../hooks/useMediaLibraryEditor.js";
|
|
10
|
+
import { useMathsModal } from "../../hooks/useMathsModal.js";
|
|
11
|
+
import { useImageModal } from "../../hooks/useImageModal.js";
|
|
12
|
+
import { useLinkToolbar } from "../../hooks/useLinkToolbar.js";
|
|
13
|
+
import { useSpeechSynthetisis } from "../../hooks/useSpeechSynthetisis.js";
|
|
14
|
+
import { EditorContext } from "../../hooks/useEditorContext.js";
|
|
15
|
+
import { EditorToolbar } from "../EditorToolbar/EditorToolbar.js";
|
|
16
|
+
import LinkToolbar from "../Toolbar/LinkToolbar.js";
|
|
17
|
+
import TableToolbar from "../Toolbar/TableToolbar.js";
|
|
18
|
+
import BubbleMenuEditImage from "../BubbleMenuEditImage/BubbleMenuEditImage.js";
|
|
19
|
+
import MediaLibrary from "../../../multimedia/MediaLibrary/MediaLibrary.js";
|
|
20
|
+
import LoadingScreen from "../../../../components/LoadingScreen/LoadingScreen.js";
|
|
21
|
+
const MathsModal = /* @__PURE__ */ lazy(async () => await import("../MathsModal/MathsModal.js")), ImageEditor = /* @__PURE__ */ lazy(async () => await import("../../../multimedia/ImageEditor/components/ImageEditor.js")), Editor = /* @__PURE__ */ forwardRef(({
|
|
22
|
+
id,
|
|
23
|
+
content,
|
|
24
|
+
mode = "read",
|
|
25
|
+
toolbar = "full",
|
|
26
|
+
variant = "outline",
|
|
27
|
+
focus = "start",
|
|
28
|
+
placeholder = "",
|
|
29
|
+
visibility = "protected",
|
|
30
|
+
onContentChange
|
|
31
|
+
}, ref) => {
|
|
32
|
+
const editorId = useId(), {
|
|
33
|
+
appCode
|
|
34
|
+
} = useEdificeClient(), {
|
|
35
|
+
editor,
|
|
36
|
+
editable
|
|
37
|
+
} = useTipTapEditor(mode === "edit", content, focus, placeholder, onContentChange, visibility), {
|
|
38
|
+
ref: mediaLibraryModalRef,
|
|
39
|
+
...mediaLibraryModalHandlers
|
|
40
|
+
} = useMediaLibraryEditor(editor), {
|
|
41
|
+
toggle: toggleMathsModal,
|
|
42
|
+
...mathsModalHandlers
|
|
43
|
+
} = useMathsModal(editor), imageModal = useImageModal(editor, "media-library", visibility), linkToolbarHandlers = useLinkToolbar(editor, mediaLibraryModalRef), speechSynthetisis = useSpeechSynthetisis(editor);
|
|
44
|
+
if (useMathsStyles(), useImperativeHandle(ref, () => ({
|
|
45
|
+
getContent: (as) => {
|
|
46
|
+
switch (as) {
|
|
47
|
+
case "html":
|
|
48
|
+
return editor == null ? void 0 : editor.getHTML();
|
|
49
|
+
case "json":
|
|
50
|
+
return editor == null ? void 0 : editor.getJSON();
|
|
51
|
+
case "plain":
|
|
52
|
+
return editor == null ? void 0 : editor.getText();
|
|
53
|
+
default:
|
|
54
|
+
throw `[Editor] Unknown content format ${as}`;
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
toogleSpeechSynthetisis: speechSynthetisis.toggle,
|
|
58
|
+
isSpeeching: () => speechSynthetisis.isActivated
|
|
59
|
+
})), !editor) return null;
|
|
60
|
+
const borderClass = clsx(variant === "outline" && "border rounded-3"), contentClass = clsx(variant === "outline" && "py-12 px-16");
|
|
61
|
+
return /* @__PURE__ */ jsxs(EditorContext.Provider, { value: {
|
|
62
|
+
id: id ?? editorId,
|
|
63
|
+
appCode,
|
|
64
|
+
editor,
|
|
65
|
+
editable
|
|
66
|
+
}, children: [
|
|
67
|
+
/* @__PURE__ */ jsxs("div", { className: borderClass, children: [
|
|
68
|
+
toolbar !== "none" && editable && /* @__PURE__ */ jsx(EditorToolbar, { mediaLibraryRef: mediaLibraryModalRef, toggleMathsModal }),
|
|
69
|
+
/* @__PURE__ */ jsx(EditorContent, { id: id ?? editorId, editor, className: contentClass })
|
|
70
|
+
] }),
|
|
71
|
+
/* @__PURE__ */ jsx(LinkToolbar, { editor, ...linkToolbarHandlers }),
|
|
72
|
+
/* @__PURE__ */ jsx(TableToolbar, { editor }),
|
|
73
|
+
editor && /* @__PURE__ */ jsx(BubbleMenuEditImage, { editor, onEditImage: imageModal.handleEdit, openEditImage: imageModal.isOpen, editable }),
|
|
74
|
+
/* @__PURE__ */ jsxs(Suspense, { fallback: /* @__PURE__ */ jsx(LoadingScreen, {}), children: [
|
|
75
|
+
editable && /* @__PURE__ */ jsx(MediaLibrary, { appCode, visibility, multiple: !0, ref: mediaLibraryModalRef, ...mediaLibraryModalHandlers }),
|
|
76
|
+
editable && mathsModalHandlers.isOpen && /* @__PURE__ */ jsx(MathsModal, { ...mathsModalHandlers }),
|
|
77
|
+
editable && (imageModal == null ? void 0 : imageModal.isOpen) && (imageModal == null ? void 0 : imageModal.currentImage) && /* @__PURE__ */ jsx(ImageEditor, { altText: imageModal == null ? void 0 : imageModal.currentImage.alt, legend: imageModal == null ? void 0 : imageModal.currentImage.title, image: imageModal == null ? void 0 : imageModal.currentImage.src, isOpen: imageModal.isOpen, onCancel: imageModal.handleCancel, onSave: imageModal.handleSave, onError: console.error })
|
|
78
|
+
] })
|
|
79
|
+
] });
|
|
80
|
+
});
|
|
81
|
+
export {
|
|
82
|
+
Editor as default
|
|
83
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useState, useEffect } from "react";
|
|
3
|
+
import Mathematics from "@tiptap-pro/extension-mathematics";
|
|
4
|
+
import { useEditor, EditorContent } from "@tiptap/react";
|
|
5
|
+
import StarterKit from "@tiptap/starter-kit";
|
|
6
|
+
import { useTranslation } from "react-i18next";
|
|
7
|
+
import Modal from "../../../../components/Modal/Modal.js";
|
|
8
|
+
import Button from "../../../../components/Button/Button.js";
|
|
9
|
+
const MathsModal = ({
|
|
10
|
+
isOpen,
|
|
11
|
+
onSuccess,
|
|
12
|
+
onCancel
|
|
13
|
+
}) => {
|
|
14
|
+
const FORMULA_PLACEHOLDER = "\\frac{-b + \\sqrt{b^2 - 4ac}}{2a}", [formulaEditor, setFormulaEditor] = useState(`$${FORMULA_PLACEHOLDER}$`), {
|
|
15
|
+
t
|
|
16
|
+
} = useTranslation(), editor = useEditor({
|
|
17
|
+
extensions: [StarterKit, Mathematics],
|
|
18
|
+
content: "",
|
|
19
|
+
editable: !1
|
|
20
|
+
});
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
editor == null || editor.commands.setContent(formulaEditor), editor == null || editor.commands.enter();
|
|
23
|
+
}, [editor, formulaEditor]);
|
|
24
|
+
const handleChange = (event) => {
|
|
25
|
+
const newFormulaEditor = event.target.value.replaceAll(`
|
|
26
|
+
`, "$<br/>$");
|
|
27
|
+
newFormulaEditor ? (editor == null || editor.commands.setContent(`$${newFormulaEditor}$`), setFormulaEditor(`$${newFormulaEditor}$`)) : (editor == null || editor.commands.setContent(""), setFormulaEditor("")), editor == null || editor.commands.enter();
|
|
28
|
+
}, handleOnCancel = () => {
|
|
29
|
+
onCancel == null || onCancel();
|
|
30
|
+
};
|
|
31
|
+
return /* @__PURE__ */ jsxs(Modal, { id: "MathsModal", isOpen, onModalClose: handleOnCancel, children: [
|
|
32
|
+
/* @__PURE__ */ jsx(Modal.Header, { onModalClose: handleOnCancel, children: t("tiptap.maths.title") }),
|
|
33
|
+
/* @__PURE__ */ jsxs(Modal.Subtitle, { children: [
|
|
34
|
+
t("tiptap.maths.subtitle.1"),
|
|
35
|
+
/* @__PURE__ */ jsx("a", { href: t("https://fr.wikibooks.org/wiki/LaTeX/%C3%89crire_des_math%C3%A9matiques"), target: "_blank", children: t("tiptap.maths.subtitle.2") })
|
|
36
|
+
] }),
|
|
37
|
+
/* @__PURE__ */ jsxs(Modal.Body, { children: [
|
|
38
|
+
/* @__PURE__ */ jsx("textarea", { id: "formulaTextArea", name: "formula", rows: 4, cols: 50, onChange: handleChange, placeholder: `Exemple : ${FORMULA_PLACEHOLDER}`, className: "border rounded-3 w-100 px-16 py-12" }),
|
|
39
|
+
/* @__PURE__ */ jsx(EditorContent, { editor, className: "pt-24 pb-0 text-center fs-1" })
|
|
40
|
+
] }),
|
|
41
|
+
/* @__PURE__ */ jsxs(Modal.Footer, { children: [
|
|
42
|
+
/* @__PURE__ */ jsx(Button, { color: "tertiary", onClick: onCancel, type: "button", variant: "ghost", children: t("tiptap.maths.cancel") }),
|
|
43
|
+
/* @__PURE__ */ jsx(Button, { color: "primary", onClick: () => onSuccess == null ? void 0 : onSuccess(formulaEditor), type: "button", variant: "filled", children: t("tiptap.maths.add") })
|
|
44
|
+
] })
|
|
45
|
+
] });
|
|
46
|
+
};
|
|
47
|
+
export {
|
|
48
|
+
MathsModal as default
|
|
49
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { useEffect } from "react";
|
|
2
|
+
const useMathsStyles = () => {
|
|
3
|
+
useEffect(() => {
|
|
4
|
+
const katexURL = "https://cdn.jsdelivr.net/npm/katex@0.16.10/dist/katex.min.css";
|
|
5
|
+
let hasKatexLink = !1;
|
|
6
|
+
const links = document.head.getElementsByTagName("link");
|
|
7
|
+
for (const link of links)
|
|
8
|
+
if (link.href === katexURL) {
|
|
9
|
+
hasKatexLink = !0;
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
if (!hasKatexLink) {
|
|
13
|
+
const link = document.createElement("link");
|
|
14
|
+
link.href = katexURL, link.rel = "stylesheet", link.type = "text/css", document.head.appendChild(link);
|
|
15
|
+
}
|
|
16
|
+
}, []);
|
|
17
|
+
};
|
|
18
|
+
export {
|
|
19
|
+
useMathsStyles
|
|
20
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { default as StarterKit } from '@tiptap/starter-kit';
|
|
2
|
-
export { EditorContent, type Content, useEditor, Editor } from '@tiptap/react';
|
|
2
|
+
export { EditorContent, type Content, useEditor, Editor as TipTapEditor } from '@tiptap/react';
|
|
3
3
|
export { StarterKit };
|
|
4
4
|
export * from './components';
|
|
5
5
|
export * from './hooks';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@edifice.io/react",
|
|
3
|
-
"version": "2.0.5-develop-pedago.
|
|
3
|
+
"version": "2.0.5-develop-pedago.20250212101448",
|
|
4
4
|
"description": "Edifice React Library",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -118,9 +118,9 @@
|
|
|
118
118
|
"react-slugify": "^3.0.3",
|
|
119
119
|
"swiper": "^10.1.0",
|
|
120
120
|
"ua-parser-js": "^1.0.36",
|
|
121
|
-
"@edifice.io/bootstrap": "2.0.5-develop-pedago.
|
|
122
|
-
"@edifice.io/
|
|
123
|
-
"@edifice.io/
|
|
121
|
+
"@edifice.io/bootstrap": "2.0.5-develop-pedago.20250212101448",
|
|
122
|
+
"@edifice.io/tiptap-extensions": "2.0.5-develop-pedago.20250212101448",
|
|
123
|
+
"@edifice.io/utilities": "2.0.5-develop-pedago.20250212101448"
|
|
124
124
|
},
|
|
125
125
|
"devDependencies": {
|
|
126
126
|
"@babel/plugin-transform-react-pure-annotations": "^7.23.3",
|
|
@@ -148,8 +148,8 @@
|
|
|
148
148
|
"vite": "^5.4.11",
|
|
149
149
|
"vite-plugin-dts": "^4.1.0",
|
|
150
150
|
"vite-tsconfig-paths": "^5.0.1",
|
|
151
|
-
"@edifice.io/
|
|
152
|
-
"@edifice.io/
|
|
151
|
+
"@edifice.io/config": "2.0.5-develop-pedago.20250212101448",
|
|
152
|
+
"@edifice.io/client": "2.0.5-develop-pedago.20250212101448"
|
|
153
153
|
},
|
|
154
154
|
"peerDependencies": {
|
|
155
155
|
"@react-spring/web": "^9.7.5",
|