@edifice.io/react 2.6.9 → 2.6.10-chore-tiptap-v3.20261021191834
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/components/RadioTile/RadioTile.d.ts +35 -0
- package/dist/components/RadioTile/RadioTile.js +22 -0
- package/dist/components/RadioTile/index.d.ts +2 -0
- package/dist/components/Tree/utilities/tree.js +21 -1
- package/dist/components/index.d.ts +1 -0
- package/dist/editor.js +2 -0
- package/dist/hooks/index.d.ts +2 -0
- package/dist/hooks/useBackground/useBackground.d.ts +1 -1
- package/dist/hooks/useCarbonioUnread/index.d.ts +1 -0
- package/dist/hooks/useCarbonioUnread/useCarbonioUnread.d.ts +5 -0
- package/dist/hooks/useCarbonioUnread/useCarbonioUnread.js +24 -0
- package/dist/hooks/useNextcloudSearch/index.d.ts +1 -0
- package/dist/hooks/useNextcloudSearch/useNextcloudSearch.d.ts +14 -0
- package/dist/hooks/useNextcloudSearch/useNextcloudSearch.js +64 -0
- package/dist/hooks/useZendeskGuide/useZendeskGuide.d.ts +1 -1
- package/dist/index.js +160 -150
- 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/Header/Header.js +10 -3
- package/dist/modules/multimedia/FileCard/NextcloudFileCard.d.ts +25 -0
- package/dist/modules/multimedia/FileCard/NextcloudFileCard.js +102 -0
- package/dist/modules/multimedia/FileCard/index.d.ts +2 -0
- package/dist/modules/multimedia/MediaLibrary/MediaLibrary.d.ts +4 -2
- package/dist/modules/multimedia/MediaLibrary/MediaLibrary.js +38 -11
- package/dist/modules/multimedia/MediaLibrary/MediaLibraryContext.d.ts +4 -0
- package/dist/modules/multimedia/MediaLibrary/innertabs/Nextcloud.d.ts +1 -0
- package/dist/modules/multimedia/MediaLibrary/innertabs/Nextcloud.js +48 -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 +1 -0
- package/dist/modules/multimedia/MediaLibrary/innertabs/index.js +2 -0
- package/dist/modules/multimedia/Nextcloud/Nextcloud.d.ts +24 -0
- package/dist/modules/multimedia/Nextcloud/Nextcloud.js +120 -0
- package/dist/modules/multimedia/Nextcloud/index.d.ts +2 -0
- package/dist/modules/multimedia/Workspace/Workspace.js +8 -5
- package/dist/modules/multimedia/index.d.ts +1 -0
- package/dist/multimedia.js +16 -12
- 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/modules/editor/components/Toolbar/LinkToolbar.TippyOptions.d.ts +0 -2
- package/dist/modules/editor/components/Toolbar/LinkToolbar.TippyOptions.js +0 -8
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useMemo } from "react";
|
|
3
|
-
import { BubbleMenu } from "@tiptap/react";
|
|
2
|
+
import { useState, useEffect, useMemo, useCallback } from "react";
|
|
3
|
+
import { BubbleMenu } from "../../../../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";
|
|
4
4
|
import { useTranslation } from "react-i18next";
|
|
5
|
+
import { useEditorState } from "../../hooks/useEditorState.js";
|
|
5
6
|
import { Toolbar } from "../../../../components/Toolbar/Toolbar.js";
|
|
7
|
+
import { getFloatingMenuOptions, useReferencedVirtualElement, FLOATING_MENU_Z_INDEX } from "../Toolbar/FloatingMenuOptions.js";
|
|
6
8
|
import SvgIconAlertTriangle from "../../../icons/components/IconAlertTriangle.js";
|
|
7
9
|
import SvgIconDelete from "../../../icons/components/IconDelete.js";
|
|
8
10
|
import SvgIconInfoCircle from "../../../icons/components/IconInfoCircle.js";
|
|
@@ -14,98 +16,105 @@ const BubbleMenuEditInformationPane = ({
|
|
|
14
16
|
}) => {
|
|
15
17
|
const {
|
|
16
18
|
t
|
|
17
|
-
} = useTranslation(),
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
onClick: () => editor.chain().focus().updateAttributes("information-pane", {
|
|
30
|
-
type: "info"
|
|
31
|
-
}).run()
|
|
32
|
-
},
|
|
33
|
-
tooltip: {
|
|
34
|
-
message: t("tiptap.tooltip.bubblemenu.information.pane.info"),
|
|
35
|
-
position: "top"
|
|
36
|
-
}
|
|
37
|
-
}, {
|
|
38
|
-
type: "icon",
|
|
39
|
-
name: "success",
|
|
40
|
-
props: {
|
|
41
|
-
size: "lg",
|
|
42
|
-
icon: /* @__PURE__ */ jsx(SvgIconSuccessOutline, {}),
|
|
43
|
-
"aria-label": t("tiptap.tooltip.bubblemenu.information.pane.success"),
|
|
44
|
-
className: ((_b = selectedNode == null ? void 0 : selectedNode.attrs) == null ? void 0 : _b.type) === "success" ? "is-selected" : "",
|
|
45
|
-
onClick: () => editor.chain().focus().updateAttributes("information-pane", {
|
|
46
|
-
type: "success"
|
|
47
|
-
}).run()
|
|
48
|
-
},
|
|
49
|
-
tooltip: {
|
|
50
|
-
message: t("tiptap.tooltip.bubblemenu.information.pane.success"),
|
|
51
|
-
position: "top"
|
|
52
|
-
}
|
|
53
|
-
}, {
|
|
54
|
-
type: "icon",
|
|
55
|
-
name: "warning",
|
|
56
|
-
props: {
|
|
57
|
-
size: "lg",
|
|
58
|
-
icon: /* @__PURE__ */ jsx(SvgIconAlertTriangle, {}),
|
|
59
|
-
"aria-label": t("tiptap.tooltip.bubblemenu.information.pane.warning"),
|
|
60
|
-
className: ((_c = selectedNode == null ? void 0 : selectedNode.attrs) == null ? void 0 : _c.type) === "warning" ? "is-selected" : "",
|
|
61
|
-
onClick: () => editor.chain().focus().updateAttributes("information-pane", {
|
|
62
|
-
type: "warning"
|
|
63
|
-
}).run()
|
|
64
|
-
},
|
|
65
|
-
tooltip: {
|
|
66
|
-
message: t("tiptap.tooltip.bubblemenu.information.pane.warning"),
|
|
67
|
-
position: "top"
|
|
19
|
+
} = useTranslation(), editorState = useEditorState(editor), [currentType, setCurrentType] = useState(null);
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
var _a;
|
|
22
|
+
const {
|
|
23
|
+
$anchor
|
|
24
|
+
} = editor.view.state.selection;
|
|
25
|
+
let selectedNode = null;
|
|
26
|
+
for (let depth = $anchor.depth; depth >= 0; depth--) {
|
|
27
|
+
const node = $anchor.node(depth);
|
|
28
|
+
if (node.type.name === "information-pane") {
|
|
29
|
+
selectedNode = node;
|
|
30
|
+
break;
|
|
68
31
|
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
32
|
+
}
|
|
33
|
+
setCurrentType(((_a = selectedNode == null ? void 0 : selectedNode.attrs) == null ? void 0 : _a.type) ?? null);
|
|
34
|
+
}, [editor, editorState]);
|
|
35
|
+
const InformationPaneTypeItems = useMemo(() => [{
|
|
36
|
+
type: "icon",
|
|
37
|
+
name: "info",
|
|
38
|
+
props: {
|
|
39
|
+
size: "lg",
|
|
40
|
+
icon: /* @__PURE__ */ jsx(SvgIconInfoCircle, {}),
|
|
41
|
+
"aria-label": t("tiptap.tooltip.bubblemenu.information.pane.info"),
|
|
42
|
+
className: currentType === "info" ? "is-selected" : "",
|
|
43
|
+
onClick: () => editor.chain().focus().updateAttributes("information-pane", {
|
|
44
|
+
type: "info"
|
|
45
|
+
}).run()
|
|
46
|
+
},
|
|
47
|
+
tooltip: {
|
|
48
|
+
message: t("tiptap.tooltip.bubblemenu.information.pane.info"),
|
|
49
|
+
position: "top"
|
|
50
|
+
}
|
|
51
|
+
}, {
|
|
52
|
+
type: "icon",
|
|
53
|
+
name: "success",
|
|
54
|
+
props: {
|
|
55
|
+
size: "lg",
|
|
56
|
+
icon: /* @__PURE__ */ jsx(SvgIconSuccessOutline, {}),
|
|
57
|
+
"aria-label": t("tiptap.tooltip.bubblemenu.information.pane.success"),
|
|
58
|
+
className: currentType === "success" ? "is-selected" : "",
|
|
59
|
+
onClick: () => editor.chain().focus().updateAttributes("information-pane", {
|
|
60
|
+
type: "success"
|
|
61
|
+
}).run()
|
|
62
|
+
},
|
|
63
|
+
tooltip: {
|
|
64
|
+
message: t("tiptap.tooltip.bubblemenu.information.pane.success"),
|
|
65
|
+
position: "top"
|
|
66
|
+
}
|
|
67
|
+
}, {
|
|
68
|
+
type: "icon",
|
|
69
|
+
name: "warning",
|
|
70
|
+
props: {
|
|
71
|
+
size: "lg",
|
|
72
|
+
icon: /* @__PURE__ */ jsx(SvgIconAlertTriangle, {}),
|
|
73
|
+
"aria-label": t("tiptap.tooltip.bubblemenu.information.pane.warning"),
|
|
74
|
+
className: currentType === "warning" ? "is-selected" : "",
|
|
75
|
+
onClick: () => editor.chain().focus().updateAttributes("information-pane", {
|
|
76
|
+
type: "warning"
|
|
77
|
+
}).run()
|
|
78
|
+
},
|
|
79
|
+
tooltip: {
|
|
80
|
+
message: t("tiptap.tooltip.bubblemenu.information.pane.warning"),
|
|
81
|
+
position: "top"
|
|
82
|
+
}
|
|
83
|
+
}, {
|
|
84
|
+
type: "icon",
|
|
85
|
+
name: "question",
|
|
86
|
+
props: {
|
|
87
|
+
size: "lg",
|
|
88
|
+
icon: /* @__PURE__ */ jsx(SvgIconQuestion, {}),
|
|
89
|
+
"aria-label": t("tiptap.tooltip.bubblemenu.information.pane.question"),
|
|
90
|
+
className: currentType === "question" ? "is-selected" : "",
|
|
91
|
+
onClick: () => editor.chain().focus().updateAttributes("information-pane", {
|
|
92
|
+
type: "question"
|
|
93
|
+
}).run()
|
|
94
|
+
},
|
|
95
|
+
tooltip: {
|
|
96
|
+
message: t("tiptap.tooltip.bubblemenu.information.pane.question"),
|
|
97
|
+
position: "top"
|
|
98
|
+
}
|
|
99
|
+
}, {
|
|
100
|
+
type: "divider",
|
|
101
|
+
name: "div-4"
|
|
102
|
+
}, {
|
|
103
|
+
type: "button",
|
|
104
|
+
name: "delete",
|
|
105
|
+
props: {
|
|
106
|
+
size: "lg",
|
|
107
|
+
leftIcon: /* @__PURE__ */ jsx(SvgIconDelete, {}),
|
|
108
|
+
"aria-label": t("tiptap.bubblemenu.delete"),
|
|
109
|
+
children: t("tiptap.bubblemenu.delete"),
|
|
110
|
+
onClick: () => editor.chain().focus().deleteNode("information-pane").run()
|
|
111
|
+
},
|
|
112
|
+
tooltip: {
|
|
113
|
+
message: t("tiptap.bubblemenu.delete"),
|
|
114
|
+
position: "top"
|
|
115
|
+
}
|
|
116
|
+
}], [t, editor, currentType]), reference = useMemo(() => ({
|
|
117
|
+
getBoundingClientRect: () => {
|
|
109
118
|
const {
|
|
110
119
|
state
|
|
111
120
|
} = editor, {
|
|
@@ -126,10 +135,28 @@ const BubbleMenuEditInformationPane = ({
|
|
|
126
135
|
}
|
|
127
136
|
return new DOMRect(0, 0, 0, 0);
|
|
128
137
|
}
|
|
129
|
-
}), [editor])
|
|
130
|
-
|
|
138
|
+
}), [editor]), floatingOptions = useMemo(() => getFloatingMenuOptions({
|
|
139
|
+
placement: "bottom",
|
|
140
|
+
offset: {
|
|
141
|
+
mainAxis: 0,
|
|
142
|
+
crossAxis: 0
|
|
143
|
+
}
|
|
144
|
+
}), []), getReferencedVirtualElement = useReferencedVirtualElement(reference), handleShouldShow = useCallback(({
|
|
131
145
|
editor: editor2
|
|
132
|
-
}) => editor2.isActive("information-pane"),
|
|
146
|
+
}) => editor2.isActive("information-pane"), []);
|
|
147
|
+
return /* @__PURE__ */ jsx(
|
|
148
|
+
BubbleMenu,
|
|
149
|
+
{
|
|
150
|
+
shouldShow: handleShouldShow,
|
|
151
|
+
editor,
|
|
152
|
+
options: floatingOptions,
|
|
153
|
+
getReferencedVirtualElement,
|
|
154
|
+
style: {
|
|
155
|
+
zIndex: FLOATING_MENU_Z_INDEX
|
|
156
|
+
},
|
|
157
|
+
children: editable && /* @__PURE__ */ jsx(Toolbar, { className: "p-8", items: InformationPaneTypeItems })
|
|
158
|
+
}
|
|
159
|
+
);
|
|
133
160
|
};
|
|
134
161
|
export {
|
|
135
162
|
BubbleMenuEditInformationPane as default
|
|
@@ -3,6 +3,7 @@ import { useState, useMemo, useCallback, useEffect } from "react";
|
|
|
3
3
|
import { useTranslation } from "react-i18next";
|
|
4
4
|
import SvgIconTextHighlight from "../../../icons/components/IconTextHighlight.js";
|
|
5
5
|
import { useEditorContext } from "../../hooks/useEditorContext.js";
|
|
6
|
+
import { useEditorState } from "../../hooks/useEditorState.js";
|
|
6
7
|
import { DefaultPalette } from "../../../../components/ColorPicker/ColorPalette.js";
|
|
7
8
|
import Tooltip from "../../../../components/Tooltip/Tooltip.js";
|
|
8
9
|
import IconButton from "../../../../components/Button/IconButton.js";
|
|
@@ -16,20 +17,16 @@ const EditorToolbarHighlightColor = ({
|
|
|
16
17
|
t
|
|
17
18
|
} = useTranslation(), {
|
|
18
19
|
editor
|
|
19
|
-
} = useEditorContext(), [color, setColor] = useState("#4A4A4A"), isActive = useMemo(
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}),
|
|
23
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
24
|
-
[editor, editor == null ? void 0 : editor.state]
|
|
25
|
-
), applyColor = useCallback((value) => {
|
|
20
|
+
} = useEditorContext(), [color, setColor] = useState("#4A4A4A"), editorState = useEditorState(editor), isActive = useMemo(() => editor == null ? void 0 : editor.isActive("customHighlight", {
|
|
21
|
+
color: /^#([0-9a-f]{3}){1,2}$/i
|
|
22
|
+
}), [editor, editorState]), applyColor = useCallback((value) => {
|
|
26
23
|
value === color || value === "" ? (setColor(""), editor == null || editor.chain().focus().unsetHighlight().run()) : (setColor(value), editor == null || editor.chain().focus().setHighlight({
|
|
27
24
|
color: value
|
|
28
25
|
}).run());
|
|
29
26
|
}, [color, editor]);
|
|
30
27
|
useEffect(() => {
|
|
31
28
|
setColor((editor == null ? void 0 : editor.getAttributes("customHighlight").color) ?? "");
|
|
32
|
-
}, [editor,
|
|
29
|
+
}, [editor, editorState]);
|
|
33
30
|
const palettes = [{
|
|
34
31
|
...DefaultPalette,
|
|
35
32
|
reset: {
|
|
@@ -3,6 +3,7 @@ import { useState, useMemo, useCallback, useEffect } from "react";
|
|
|
3
3
|
import { useTranslation } from "react-i18next";
|
|
4
4
|
import SvgIconTextColor from "../../../icons/components/IconTextColor.js";
|
|
5
5
|
import { useEditorContext } from "../../hooks/useEditorContext.js";
|
|
6
|
+
import { useEditorState } from "../../hooks/useEditorState.js";
|
|
6
7
|
import { DefaultPalette, AccessiblePalette } from "../../../../components/ColorPicker/ColorPalette.js";
|
|
7
8
|
import Tooltip from "../../../../components/Tooltip/Tooltip.js";
|
|
8
9
|
import IconButton from "../../../../components/Button/IconButton.js";
|
|
@@ -16,19 +17,15 @@ const EditorToolbarTextColor = ({
|
|
|
16
17
|
t
|
|
17
18
|
} = useTranslation(), {
|
|
18
19
|
editor
|
|
19
|
-
} = useEditorContext(), [color, setColor] = useState("#4A4A4A"), isActive = useMemo(
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}),
|
|
23
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
24
|
-
[editor, editor == null ? void 0 : editor.state]
|
|
25
|
-
), applyColor = useCallback((value) => {
|
|
20
|
+
} = useEditorContext(), [color, setColor] = useState("#4A4A4A"), editorState = useEditorState(editor), isActive = useMemo(() => editor == null ? void 0 : editor.isActive("textStyle", {
|
|
21
|
+
color: /^#([0-9a-f]{3}){1,2}$/i
|
|
22
|
+
}), [editor, editorState]), applyColor = useCallback((value) => {
|
|
26
23
|
value === color ? (setColor(""), editor == null || editor.chain().focus().unsetColor().run()) : (setColor(value), editor == null || editor.chain().focus().setColor(value).run());
|
|
27
24
|
}, [color, editor]);
|
|
28
25
|
useEffect(() => {
|
|
29
26
|
const textStyle = editor == null ? void 0 : editor.getAttributes("textStyle");
|
|
30
27
|
setColor((textStyle == null ? void 0 : textStyle.color) ?? "#4A4A4A");
|
|
31
|
-
}, [editor,
|
|
28
|
+
}, [editor, editorState]);
|
|
32
29
|
const palettes = [{
|
|
33
30
|
...DefaultPalette,
|
|
34
31
|
label: t("tiptap.toolbar.color.text")
|
|
@@ -3,6 +3,7 @@ import { useState, useEffect, Fragment as Fragment$1 } from "react";
|
|
|
3
3
|
import { useTranslation } from "react-i18next";
|
|
4
4
|
import SvgIconTextTypo from "../../../icons/components/IconTextTypo.js";
|
|
5
5
|
import { useEditorContext } from "../../hooks/useEditorContext.js";
|
|
6
|
+
import { useEditorState } from "../../hooks/useEditorState.js";
|
|
6
7
|
import Tooltip from "../../../../components/Tooltip/Tooltip.js";
|
|
7
8
|
import IconButton from "../../../../components/Button/IconButton.js";
|
|
8
9
|
import Dropdown from "../../../../components/Dropdown/Dropdown.js";
|
|
@@ -13,11 +14,11 @@ const EditorToolbarTypography = ({
|
|
|
13
14
|
t
|
|
14
15
|
} = useTranslation(), {
|
|
15
16
|
editor
|
|
16
|
-
} = useEditorContext(), [value, setValue] = useState("sans-serif");
|
|
17
|
+
} = useEditorContext(), [value, setValue] = useState("sans-serif"), editorState = useEditorState(editor);
|
|
17
18
|
useEffect(() => {
|
|
18
19
|
const textStyle = editor == null ? void 0 : editor.getAttributes("textStyle");
|
|
19
20
|
setValue((textStyle == null ? void 0 : textStyle.fontFamily) ?? "");
|
|
20
|
-
}, [editor,
|
|
21
|
+
}, [editor, editorState]);
|
|
21
22
|
const options = [{
|
|
22
23
|
value: "",
|
|
23
24
|
label: t("tiptap.toolbar.typo.sans")
|
|
@@ -29,6 +29,7 @@ import { EditorToolbarTextSize } from "./EditorToolbar.TextSize.js";
|
|
|
29
29
|
import { EditorToolbarTypography } from "./EditorToolbar.Typography.js";
|
|
30
30
|
import { EditorToolbarCantoo } from "./EditorToolbar.Cantoo.js";
|
|
31
31
|
import { useEditorContext } from "../../hooks/useEditorContext.js";
|
|
32
|
+
import { useEditorState } from "../../hooks/useEditorState.js";
|
|
32
33
|
import { useActionOptions } from "../../hooks/useActionOptions.js";
|
|
33
34
|
import { useSpeechRecognition } from "../../hooks/useSpeechRecognition.js";
|
|
34
35
|
import { Toolbar } from "../../../../components/Toolbar/Toolbar.js";
|
|
@@ -42,7 +43,7 @@ const EditorToolbar = ({
|
|
|
42
43
|
} = useTranslation(), {
|
|
43
44
|
id,
|
|
44
45
|
editor
|
|
45
|
-
} = useEditorContext(), [plusOptions, listOptions, alignmentOptions] = useActionOptions(editor, toggleMathsModal, mediaLibraryRef), {
|
|
46
|
+
} = useEditorContext(), editorState = useEditorState(editor), [plusOptions, listOptions, alignmentOptions] = useActionOptions(editor, toggleMathsModal, mediaLibraryRef), {
|
|
46
47
|
isAvailable: canRecognizeSpeech,
|
|
47
48
|
isActive: speechRecognition,
|
|
48
49
|
toggle: toggleSpeechRecognition
|
|
@@ -72,7 +73,8 @@ const EditorToolbar = ({
|
|
|
72
73
|
},
|
|
73
74
|
name: "undo",
|
|
74
75
|
tooltip: t("editor.option.undo"),
|
|
75
|
-
|
|
76
|
+
// v3's StarterKit renamed the undo/redo extension from 'history' to 'undoRedo'.
|
|
77
|
+
visibility: showIf(hasExtension("undoRedo", editor))
|
|
76
78
|
},
|
|
77
79
|
//--------------- REDO ---------------//
|
|
78
80
|
{
|
|
@@ -85,7 +87,7 @@ const EditorToolbar = ({
|
|
|
85
87
|
},
|
|
86
88
|
name: "redo",
|
|
87
89
|
tooltip: t("editor.option.redo"),
|
|
88
|
-
visibility: showIf(hasExtension("
|
|
90
|
+
visibility: showIf(hasExtension("undoRedo", editor))
|
|
89
91
|
},
|
|
90
92
|
//-------------------------------------//
|
|
91
93
|
{
|
|
@@ -348,7 +350,7 @@ const EditorToolbar = ({
|
|
|
348
350
|
visibility: showIf(hasExtension("textAlign", editor))
|
|
349
351
|
}
|
|
350
352
|
];
|
|
351
|
-
}, [alignmentOptions, canRecognizeSpeech, editor, listOptions, mediaLibraryRef, plusOptions, speechRecognition, t, toggleSpeechRecognition]);
|
|
353
|
+
}, [alignmentOptions, canRecognizeSpeech, editor, editorState, listOptions, mediaLibraryRef, plusOptions, speechRecognition, t, toggleSpeechRecognition]);
|
|
352
354
|
return /* @__PURE__ */ jsx("div", { className: "sticky-top z-1 editor-toolbar rounded-3", children: /* @__PURE__ */ jsx(Toolbar, { items: toolbarItems, variant: "no-shadow", className: "rounded-top-3", isBlock: !0, align: "left", ariaControls: id }) });
|
|
353
355
|
};
|
|
354
356
|
export {
|
|
@@ -0,0 +1,29 @@
|
|
|
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;
|
|
@@ -0,0 +1,22 @@
|
|
|
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,15 +1,18 @@
|
|
|
1
|
+
import { HyperlinkAttributes } from '@edifice.io/tiptap-extensions/hyperlink';
|
|
2
|
+
import { LinkerAttributes } from '@edifice.io/tiptap-extensions/linker';
|
|
1
3
|
import { Editor } from '@tiptap/react';
|
|
4
|
+
type LinkAttrs = LinkerAttributes | HyperlinkAttributes;
|
|
2
5
|
interface LinkToolbarProps {
|
|
3
6
|
/**
|
|
4
7
|
* editor instance
|
|
5
8
|
*/
|
|
6
9
|
editor: Editor | null;
|
|
7
10
|
/** Handle Edit event */
|
|
8
|
-
onEdit: (attrs:
|
|
11
|
+
onEdit: (attrs: LinkAttrs | undefined) => void;
|
|
9
12
|
/** Handle Open event */
|
|
10
|
-
onOpen: (attrs:
|
|
13
|
+
onOpen: (attrs: LinkAttrs | undefined) => void;
|
|
11
14
|
/** Handle Unlink event */
|
|
12
|
-
onUnlink: (attrs:
|
|
15
|
+
onUnlink: (attrs: LinkAttrs | undefined) => void;
|
|
13
16
|
}
|
|
14
17
|
declare const LinkToolbar: ({ editor, onEdit, onOpen, onUnlink, }: LinkToolbarProps) => import("react/jsx-runtime").JSX.Element;
|
|
15
18
|
export default LinkToolbar;
|
|
@@ -1,13 +1,20 @@
|
|
|
1
1
|
import { jsx, Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { useState, useMemo, useEffect } from "react";
|
|
3
|
-
import {
|
|
2
|
+
import { useState, useMemo, useEffect, useCallback } from "react";
|
|
3
|
+
import { BubbleMenu } from "../../../../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";
|
|
4
4
|
import { useTranslation } from "react-i18next";
|
|
5
|
+
import { useEditorState } from "../../hooks/useEditorState.js";
|
|
5
6
|
import SvgIconEdit from "../../../icons/components/IconEdit.js";
|
|
6
7
|
import SvgIconExternalLink from "../../../icons/components/IconExternalLink.js";
|
|
7
8
|
import SvgIconUnlink from "../../../icons/components/IconUnlink.js";
|
|
8
|
-
import {
|
|
9
|
+
import { FLOATING_MENU_Z_INDEX, getFloatingMenuOptions } from "./FloatingMenuOptions.js";
|
|
9
10
|
import { Toolbar } from "../../../../components/Toolbar/Toolbar.js";
|
|
10
|
-
const
|
|
11
|
+
const floatingOptions = getFloatingMenuOptions({
|
|
12
|
+
placement: "bottom",
|
|
13
|
+
offset: {
|
|
14
|
+
mainAxis: 10,
|
|
15
|
+
crossAxis: 0
|
|
16
|
+
}
|
|
17
|
+
}), LinkToolbar = ({
|
|
11
18
|
editor,
|
|
12
19
|
onEdit,
|
|
13
20
|
onOpen,
|
|
@@ -15,7 +22,7 @@ const LinkToolbar = ({
|
|
|
15
22
|
}) => {
|
|
16
23
|
const {
|
|
17
24
|
t
|
|
18
|
-
} = useTranslation(), [linkAttrs, setLinkAttrs] = useState(), LinkToolbarItems = useMemo(() => [{
|
|
25
|
+
} = useTranslation(), editorState = useEditorState(editor), [linkAttrs, setLinkAttrs] = useState(), LinkToolbarItems = useMemo(() => [{
|
|
19
26
|
type: "icon",
|
|
20
27
|
name: "edit",
|
|
21
28
|
props: {
|
|
@@ -52,9 +59,24 @@ const LinkToolbar = ({
|
|
|
52
59
|
position: "bottom"
|
|
53
60
|
}
|
|
54
61
|
}], [onEdit, onOpen, onUnlink, t, linkAttrs]);
|
|
55
|
-
|
|
62
|
+
useEffect(() => {
|
|
56
63
|
editor != null && editor.isActive("linker") ? setLinkAttrs(editor.getAttributes("linker")) : editor != null && editor.isActive("hyperlink") ? setLinkAttrs(editor.getAttributes("hyperlink")) : setLinkAttrs(void 0);
|
|
57
|
-
}, [editor
|
|
64
|
+
}, [editor, editorState]);
|
|
65
|
+
const handleShouldShow = useCallback(() => (editor == null ? void 0 : editor.isEditable) && ((editor == null ? void 0 : editor.isActive("linker")) || (editor == null ? void 0 : editor.isActive("hyperlink"))) || !1, [editor]);
|
|
66
|
+
return /* @__PURE__ */ jsx(Fragment, { children: editor && // BubbleMenu, not FloatingMenu: `shouldShow` below overrides visibility
|
|
67
|
+
// either way, this only changes the default position reference.
|
|
68
|
+
/* @__PURE__ */ jsx(
|
|
69
|
+
BubbleMenu,
|
|
70
|
+
{
|
|
71
|
+
editor,
|
|
72
|
+
options: floatingOptions,
|
|
73
|
+
shouldShow: handleShouldShow,
|
|
74
|
+
style: {
|
|
75
|
+
zIndex: FLOATING_MENU_Z_INDEX
|
|
76
|
+
},
|
|
77
|
+
children: /* @__PURE__ */ jsx(Toolbar, { className: "p-4", items: LinkToolbarItems })
|
|
78
|
+
}
|
|
79
|
+
) });
|
|
58
80
|
};
|
|
59
81
|
export {
|
|
60
82
|
LinkToolbar as default
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { jsxs, Fragment, jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useState, useCallback, useEffect } from "react";
|
|
3
3
|
import { useTranslation } from "react-i18next";
|
|
4
|
+
import { useEditorState } from "../../hooks/useEditorState.js";
|
|
4
5
|
import Tooltip from "../../../../components/Tooltip/Tooltip.js";
|
|
5
6
|
import Dropdown from "../../../../components/Dropdown/Dropdown.js";
|
|
6
7
|
import ColorPickerItem from "../../../../components/ColorPicker/ColorPickerItem.js";
|
|
@@ -12,7 +13,7 @@ const TableToolbarCellColor = ({
|
|
|
12
13
|
}) => {
|
|
13
14
|
const {
|
|
14
15
|
t
|
|
15
|
-
} = useTranslation(), [color, setColor] = useState("transparent"), applyColor = useCallback((value) => {
|
|
16
|
+
} = useTranslation(), [color, setColor] = useState("transparent"), editorState = useEditorState(editor), applyColor = useCallback((value) => {
|
|
16
17
|
editor == null || editor.chain().focus().setCellAttribute(
|
|
17
18
|
"backgroundColor",
|
|
18
19
|
// reset color is transparent here => remove bkg color
|
|
@@ -21,7 +22,7 @@ const TableToolbarCellColor = ({
|
|
|
21
22
|
}, [editor, setColor]);
|
|
22
23
|
useEffect(() => {
|
|
23
24
|
setColor((editor == null ? void 0 : editor.getAttributes("tableCell").backgroundColor) ?? "transparent");
|
|
24
|
-
}, [editor,
|
|
25
|
+
}, [editor, editorState]);
|
|
25
26
|
const palettes = [{
|
|
26
27
|
...DefaultPalette,
|
|
27
28
|
label: t("tiptap.table.toolbar.cell.color"),
|