@dxos/react-ui-editor 0.8.4-main.937b3ca → 0.8.4-main.9be5663bfe
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/lib/browser/index.mjs +310 -388
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +310 -388
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/components/Editor/Editor.d.ts +9 -15
- package/dist/types/src/components/Editor/Editor.d.ts.map +1 -1
- package/dist/types/src/components/Editor/Editor.stories.d.ts.map +1 -1
- package/dist/types/src/components/EditorContent/EditorContent.d.ts.map +1 -1
- package/dist/types/src/components/EditorMenuProvider/EditorMenuProvider.d.ts +1 -3
- package/dist/types/src/components/EditorMenuProvider/EditorMenuProvider.d.ts.map +1 -1
- package/dist/types/src/components/EditorMenuProvider/menu-presets.d.ts.map +1 -1
- package/dist/types/src/components/EditorMenuProvider/useEditorMenu.d.ts.map +1 -1
- package/dist/types/src/components/EditorPreviewProvider/EditorPreviewProvider.d.ts.map +1 -1
- package/dist/types/src/components/EditorToolbar/EditorToolbar.d.ts.map +1 -1
- package/dist/types/src/components/EditorToolbar/blocks.d.ts +3 -17
- package/dist/types/src/components/EditorToolbar/blocks.d.ts.map +1 -1
- package/dist/types/src/components/EditorToolbar/formatting.d.ts +3 -17
- package/dist/types/src/components/EditorToolbar/formatting.d.ts.map +1 -1
- package/dist/types/src/components/EditorToolbar/headings.d.ts +3 -17
- package/dist/types/src/components/EditorToolbar/headings.d.ts.map +1 -1
- package/dist/types/src/components/EditorToolbar/image.d.ts +3 -8
- package/dist/types/src/components/EditorToolbar/image.d.ts.map +1 -1
- package/dist/types/src/components/EditorToolbar/index.d.ts +0 -1
- package/dist/types/src/components/EditorToolbar/index.d.ts.map +1 -1
- package/dist/types/src/components/EditorToolbar/lists.d.ts +6 -0
- package/dist/types/src/components/EditorToolbar/lists.d.ts.map +1 -0
- package/dist/types/src/components/EditorToolbar/search.d.ts +3 -8
- package/dist/types/src/components/EditorToolbar/search.d.ts.map +1 -1
- package/dist/types/src/components/EditorToolbar/view-mode.d.ts +3 -17
- package/dist/types/src/components/EditorToolbar/view-mode.d.ts.map +1 -1
- package/dist/types/src/stories/Automerge.stories.d.ts +25 -24
- package/dist/types/src/stories/Automerge.stories.d.ts.map +1 -1
- package/dist/types/src/stories/Comments.stories.d.ts +1 -1
- package/dist/types/src/stories/Comments.stories.d.ts.map +1 -1
- package/dist/types/src/stories/EditorToolbar.stories.d.ts +26 -26
- package/dist/types/src/stories/EditorToolbar.stories.d.ts.map +1 -1
- package/dist/types/src/stories/Experimental.stories.d.ts +1 -1
- package/dist/types/src/stories/Markdown.stories.d.ts +1 -1
- package/dist/types/src/stories/Outliner.stories.d.ts +2 -2
- package/dist/types/src/stories/Outliner.stories.d.ts.map +1 -1
- package/dist/types/src/stories/Popover.stories.d.ts +2 -2
- package/dist/types/src/stories/Popover.stories.d.ts.map +1 -1
- package/dist/types/src/stories/Preview.stories.d.ts +1 -1
- package/dist/types/src/stories/Preview.stories.d.ts.map +1 -1
- package/dist/types/src/stories/TextEditor.stories.d.ts +1 -1
- package/dist/types/src/stories/components/EditorStory.d.ts +3 -3
- package/dist/types/src/stories/components/EditorStory.d.ts.map +1 -1
- package/dist/types/src/stories/components/util.d.ts +3 -3
- package/dist/types/src/stories/components/util.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +24 -24
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/util/react.d.ts +1 -4
- package/dist/types/src/util/react.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +45 -45
- package/src/components/Editor/Editor.stories.tsx +6 -7
- package/src/components/Editor/Editor.tsx +21 -27
- package/src/components/EditorContent/EditorContent.tsx +1 -2
- package/src/components/EditorMenuProvider/EditorMenuProvider.tsx +21 -28
- package/src/components/EditorMenuProvider/menu-presets.ts +1 -0
- package/src/components/EditorMenuProvider/useEditorMenu.ts +8 -1
- package/src/components/EditorPreviewProvider/EditorPreviewProvider.tsx +5 -7
- package/src/components/EditorToolbar/EditorToolbar.tsx +24 -61
- package/src/components/EditorToolbar/blocks.ts +53 -46
- package/src/components/EditorToolbar/formatting.ts +44 -46
- package/src/components/EditorToolbar/headings.ts +42 -49
- package/src/components/EditorToolbar/image.ts +16 -21
- package/src/components/EditorToolbar/index.ts +0 -1
- package/src/components/EditorToolbar/lists.ts +57 -0
- package/src/components/EditorToolbar/search.ts +16 -21
- package/src/components/EditorToolbar/view-mode.ts +34 -41
- package/src/stories/Automerge.stories.tsx +10 -12
- package/src/stories/Comments.stories.tsx +4 -5
- package/src/stories/EditorToolbar.stories.tsx +32 -17
- package/src/stories/Experimental.stories.tsx +6 -6
- package/src/stories/Markdown.stories.tsx +2 -2
- package/src/stories/Outliner.stories.tsx +4 -5
- package/src/stories/Popover.stories.tsx +9 -10
- package/src/stories/Preview.stories.tsx +60 -51
- package/src/stories/Tags.stories.tsx +5 -5
- package/src/stories/TextEditor.stories.tsx +2 -2
- package/src/stories/Theme.stories.tsx +2 -2
- package/src/stories/components/EditorStory.tsx +17 -12
- package/src/stories/components/util.tsx +49 -50
- package/src/translations.ts +29 -24
- package/src/util/react.tsx +2 -11
- package/dist/types/src/components/EditorToolbar/actions.d.ts +0 -24
- package/dist/types/src/components/EditorToolbar/actions.d.ts.map +0 -1
- package/dist/types/src/stories/CommandDialog.stories.d.ts +0 -14
- package/dist/types/src/stories/CommandDialog.stories.d.ts.map +0 -1
- package/src/components/EditorToolbar/actions.ts +0 -87
- package/src/stories/CommandDialog.stories.tsx +0 -81
|
@@ -4,30 +4,30 @@ var translations = [
|
|
|
4
4
|
{
|
|
5
5
|
"en-US": {
|
|
6
6
|
[translationKey]: {
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
"heading
|
|
24
|
-
"heading
|
|
25
|
-
"heading
|
|
26
|
-
"
|
|
27
|
-
"view
|
|
28
|
-
"preview
|
|
29
|
-
"
|
|
30
|
-
"
|
|
7
|
+
"comment.label": "Create comment",
|
|
8
|
+
"image.label": "Insert image",
|
|
9
|
+
"search.label": "Search",
|
|
10
|
+
"block.label": "Block",
|
|
11
|
+
"block.blockquote.label": "Block quote",
|
|
12
|
+
"block.codeblock.label": "Code block",
|
|
13
|
+
"block.table.label": "Create table",
|
|
14
|
+
"formatting.label": "Formatting",
|
|
15
|
+
"formatting.strong.label": "Bold",
|
|
16
|
+
"formatting.emphasis.label": "Italics",
|
|
17
|
+
"formatting.strikethrough.label": "Strikethrough",
|
|
18
|
+
"formatting.code.label": "Code",
|
|
19
|
+
"formatting.link.label": "Link",
|
|
20
|
+
"list.bullet.label": "Bullet list",
|
|
21
|
+
"list.ordered.label": "Numbered list",
|
|
22
|
+
"list.task.label": "Task list",
|
|
23
|
+
"heading.label": "Heading level",
|
|
24
|
+
"heading-level.label_zero": "Paragraph",
|
|
25
|
+
"heading-level.label_one": "Heading level {{count}}",
|
|
26
|
+
"heading-level.label_other": "Heading level {{count}}",
|
|
27
|
+
"view-mode.label": "Editor view",
|
|
28
|
+
"view-mode.preview.label": "Markdown",
|
|
29
|
+
"view-mode.source.label": "Plain text",
|
|
30
|
+
"view-mode.readonly.label": "Read only"
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
}
|
|
@@ -296,7 +296,7 @@ var EditorContent = /* @__PURE__ */ forwardRef(({ classNames, id, extensions, se
|
|
|
296
296
|
]);
|
|
297
297
|
return /* @__PURE__ */ React.createElement("div", {
|
|
298
298
|
role: "none",
|
|
299
|
-
className: mx("
|
|
299
|
+
className: mx("w-full outline-hidden focus:border-accent-surface focus-within:border-neutral-focus-indicator", classNames),
|
|
300
300
|
ref: parentRef,
|
|
301
301
|
...focusable ? focusAttributes : {}
|
|
302
302
|
});
|
|
@@ -702,7 +702,7 @@ import { useControllableState } from "@radix-ui/react-use-controllable-state";
|
|
|
702
702
|
import React2, { Fragment, useCallback as useCallback2, useEffect as useEffect3, useRef as useRef2, useState as useState2 } from "react";
|
|
703
703
|
import { addEventListener } from "@dxos/async";
|
|
704
704
|
import { invariant } from "@dxos/invariant";
|
|
705
|
-
import { DX_ANCHOR_ACTIVATE, Icon, Popover, toLocalizedString, useDynamicRef, useThemeContext, useTranslation } from "@dxos/react-ui";
|
|
705
|
+
import { DX_ANCHOR_ACTIVATE, Icon, Popover, ScrollArea, toLocalizedString, useDynamicRef, useThemeContext, useTranslation } from "@dxos/react-ui";
|
|
706
706
|
var __dxlog_file2 = "/__w/dxos/dxos/packages/ui/react-ui-editor/src/components/EditorMenuProvider/EditorMenuProvider.tsx";
|
|
707
707
|
var EditorMenuProvider = ({ children, view, groups, currentItem, open: openProp, defaultOpen, numItems = 8, onOpenChange, onActivate, onSelect, onCancel }) => {
|
|
708
708
|
const { tx } = useThemeContext();
|
|
@@ -714,7 +714,7 @@ var EditorMenuProvider = ({ children, view, groups, currentItem, open: openProp,
|
|
|
714
714
|
onChange: (open2) => {
|
|
715
715
|
invariant(viewRef.current, void 0, {
|
|
716
716
|
F: __dxlog_file2,
|
|
717
|
-
L:
|
|
717
|
+
L: 64,
|
|
718
718
|
S: void 0,
|
|
719
719
|
A: [
|
|
720
720
|
"viewRef.current",
|
|
@@ -733,8 +733,8 @@ var EditorMenuProvider = ({ children, view, groups, currentItem, open: openProp,
|
|
|
733
733
|
return;
|
|
734
734
|
}
|
|
735
735
|
return addEventListener(root, DX_ANCHOR_ACTIVATE, (event) => {
|
|
736
|
-
const { trigger,
|
|
737
|
-
if (!
|
|
736
|
+
const { trigger, dxn } = event;
|
|
737
|
+
if (!dxn) {
|
|
738
738
|
triggerRef.current = trigger;
|
|
739
739
|
if (onActivate) {
|
|
740
740
|
onActivate({
|
|
@@ -756,7 +756,7 @@ var EditorMenuProvider = ({ children, view, groups, currentItem, open: openProp,
|
|
|
756
756
|
const handleSelect = useCallback2((item) => {
|
|
757
757
|
invariant(viewRef.current, void 0, {
|
|
758
758
|
F: __dxlog_file2,
|
|
759
|
-
L:
|
|
759
|
+
L: 99,
|
|
760
760
|
S: void 0,
|
|
761
761
|
A: [
|
|
762
762
|
"viewRef.current",
|
|
@@ -780,34 +780,36 @@ var EditorMenuProvider = ({ children, view, groups, currentItem, open: openProp,
|
|
|
780
780
|
virtualRef: triggerRef
|
|
781
781
|
}), /* @__PURE__ */ React2.createElement(Popover.Portal, null, /* @__PURE__ */ React2.createElement(Popover.Content, {
|
|
782
782
|
align: "start",
|
|
783
|
-
classNames:
|
|
784
|
-
|
|
785
|
-
}, [
|
|
786
|
-
"overflow-y-auto",
|
|
783
|
+
classNames: [
|
|
784
|
+
"flex flex-col",
|
|
787
785
|
!menuGroups.length && "hidden"
|
|
788
|
-
]
|
|
786
|
+
],
|
|
789
787
|
style: {
|
|
790
788
|
maxBlockSize: 36 * numItems + 10
|
|
791
789
|
},
|
|
792
|
-
|
|
793
|
-
* NOTE: We keep the focus in the editor, but Radix routes escape key.
|
|
794
|
-
*/
|
|
790
|
+
// NOTE: We keep the focus in the editor, but Radix routes escape key.
|
|
795
791
|
onEscapeKeyDown: () => {
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
792
|
+
const currentView = viewRef.current;
|
|
793
|
+
if (currentView) {
|
|
794
|
+
onCancel?.({
|
|
795
|
+
view: currentView
|
|
796
|
+
});
|
|
797
|
+
}
|
|
799
798
|
},
|
|
800
799
|
onOpenAutoFocus: (event) => event.preventDefault()
|
|
801
800
|
}, /* @__PURE__ */ React2.createElement(Popover.Viewport, {
|
|
802
|
-
|
|
803
|
-
|
|
801
|
+
asChild: true,
|
|
802
|
+
classNames: "dx-container"
|
|
803
|
+
}, /* @__PURE__ */ React2.createElement(ScrollArea.Root, {
|
|
804
|
+
thin: true
|
|
805
|
+
}, /* @__PURE__ */ React2.createElement(ScrollArea.Viewport, null, /* @__PURE__ */ React2.createElement(Menu, {
|
|
804
806
|
groups: menuGroups,
|
|
805
807
|
currentItem,
|
|
806
808
|
onSelect: handleSelect
|
|
807
|
-
})), /* @__PURE__ */ React2.createElement(Popover.Arrow, null))), /* @__PURE__ */ React2.createElement("div", {
|
|
808
|
-
ref: setRoot,
|
|
809
|
+
})))), /* @__PURE__ */ React2.createElement(Popover.Arrow, null))), /* @__PURE__ */ React2.createElement("div", {
|
|
809
810
|
role: "none",
|
|
810
|
-
className: "contents"
|
|
811
|
+
className: "contents",
|
|
812
|
+
ref: setRoot
|
|
811
813
|
}, children));
|
|
812
814
|
};
|
|
813
815
|
var Menu = ({ groups, currentItem, onSelect }) => {
|
|
@@ -819,14 +821,14 @@ var Menu = ({ groups, currentItem, onSelect }) => {
|
|
|
819
821
|
currentItem,
|
|
820
822
|
onSelect
|
|
821
823
|
}), index < groups.length - 1 && /* @__PURE__ */ React2.createElement("div", {
|
|
822
|
-
className: tx("menu.separator",
|
|
824
|
+
className: tx("menu.separator", {})
|
|
823
825
|
}))));
|
|
824
826
|
};
|
|
825
827
|
var MenuGroup = ({ group, currentItem, onSelect }) => {
|
|
826
828
|
const { tx } = useThemeContext();
|
|
827
829
|
const { t } = useTranslation();
|
|
828
830
|
return /* @__PURE__ */ React2.createElement(React2.Fragment, null, group.label && /* @__PURE__ */ React2.createElement("div", {
|
|
829
|
-
className: tx("menu.groupLabel",
|
|
831
|
+
className: tx("menu.groupLabel", {})
|
|
830
832
|
}, /* @__PURE__ */ React2.createElement("span", null, toLocalizedString(group.label, t))), group.items.map((item) => /* @__PURE__ */ React2.createElement(MenuItem, {
|
|
831
833
|
key: item.id,
|
|
832
834
|
item,
|
|
@@ -854,13 +856,12 @@ var MenuItem = ({ item, current, onSelect }) => {
|
|
|
854
856
|
]);
|
|
855
857
|
return /* @__PURE__ */ React2.createElement("li", {
|
|
856
858
|
ref: listRef,
|
|
857
|
-
className: tx("menu.item",
|
|
858
|
-
current && "bg-
|
|
859
|
+
className: tx("menu.item", {}, [
|
|
860
|
+
current && "bg-hover-surface"
|
|
859
861
|
]),
|
|
860
862
|
onClick: handleSelect
|
|
861
863
|
}, item.icon && /* @__PURE__ */ React2.createElement(Icon, {
|
|
862
|
-
icon: item.icon
|
|
863
|
-
size: 5
|
|
864
|
+
icon: item.icon
|
|
864
865
|
}), /* @__PURE__ */ React2.createElement("span", {
|
|
865
866
|
className: "grow truncate"
|
|
866
867
|
}, toLocalizedString(item.label, t)));
|
|
@@ -883,7 +884,7 @@ var useEditorMenu = ({ trigger, triggerKey, placeholder: placeholder2, filter =
|
|
|
883
884
|
trigger: trigger2,
|
|
884
885
|
...props
|
|
885
886
|
}) ?? [];
|
|
886
|
-
return filter ? filterMenuGroups(groups, (item) => text ? item.label.toLowerCase().startsWith(text.toLowerCase()) : true) : groups;
|
|
887
|
+
return filter && trigger2 !== "@" ? filterMenuGroups(groups, (item) => text ? item.label.toLowerCase().startsWith(text.toLowerCase()) : true) : groups;
|
|
887
888
|
}, [
|
|
888
889
|
getMenu,
|
|
889
890
|
filter
|
|
@@ -891,7 +892,7 @@ var useEditorMenu = ({ trigger, triggerKey, placeholder: placeholder2, filter =
|
|
|
891
892
|
const handleOpenChange = useCallback3(async ({ view, open: open2 }) => {
|
|
892
893
|
invariant2(view, void 0, {
|
|
893
894
|
F: __dxlog_file3,
|
|
894
|
-
L:
|
|
895
|
+
L: 77,
|
|
895
896
|
S: void 0,
|
|
896
897
|
A: [
|
|
897
898
|
"view",
|
|
@@ -934,10 +935,21 @@ var useEditorMenu = ({ trigger, triggerKey, placeholder: placeholder2, filter =
|
|
|
934
935
|
handleOpenChange
|
|
935
936
|
]);
|
|
936
937
|
const handleSelect = useCallback3(({ view, item }) => {
|
|
938
|
+
const { range } = view.state.field(popoverStateField) ?? {};
|
|
939
|
+
if (range) {
|
|
940
|
+
view.dispatch({
|
|
941
|
+
changes: {
|
|
942
|
+
from: range.from,
|
|
943
|
+
to: range.to,
|
|
944
|
+
insert: ""
|
|
945
|
+
}
|
|
946
|
+
});
|
|
947
|
+
}
|
|
937
948
|
void item.onSelect?.({
|
|
938
949
|
view,
|
|
939
950
|
head: view.state.selection.main.head
|
|
940
951
|
});
|
|
952
|
+
view.focus();
|
|
941
953
|
}, []);
|
|
942
954
|
const handleCancel = useCallback3(({ view }) => {
|
|
943
955
|
const { range, trigger: trigger2 } = view.state.field(popoverStateField) ?? {};
|
|
@@ -1019,144 +1031,62 @@ var useEditorMenu = ({ trigger, triggerKey, placeholder: placeholder2, filter =
|
|
|
1019
1031
|
import { Atom } from "@effect-atom/atom-react";
|
|
1020
1032
|
import React3, { memo, useMemo as useMemo3 } from "react";
|
|
1021
1033
|
import { ElevationProvider } from "@dxos/react-ui";
|
|
1022
|
-
import {
|
|
1023
|
-
|
|
1024
|
-
// src/components/EditorToolbar/actions.ts
|
|
1025
|
-
import { createMenuAction, createMenuItemGroup } from "@dxos/react-ui-menu";
|
|
1026
|
-
import { List, addList, removeList } from "@dxos/ui-editor";
|
|
1027
|
-
var listStyles = {
|
|
1028
|
-
bullet: "ph--list-bullets--regular",
|
|
1029
|
-
ordered: "ph--list-numbers--regular",
|
|
1030
|
-
task: "ph--list-checks--regular"
|
|
1031
|
-
};
|
|
1032
|
-
var createLists = (state, getView) => {
|
|
1033
|
-
const value = state.listStyle ?? "";
|
|
1034
|
-
const listGroupAction = createListGroupAction(value);
|
|
1035
|
-
const listActionsMap = createListActions(value, getView);
|
|
1036
|
-
return {
|
|
1037
|
-
nodes: [
|
|
1038
|
-
listGroupAction,
|
|
1039
|
-
...listActionsMap
|
|
1040
|
-
],
|
|
1041
|
-
edges: [
|
|
1042
|
-
{
|
|
1043
|
-
source: "root",
|
|
1044
|
-
target: "list"
|
|
1045
|
-
},
|
|
1046
|
-
...listActionsMap.map(({ id }) => ({
|
|
1047
|
-
source: listGroupAction.id,
|
|
1048
|
-
target: id
|
|
1049
|
-
}))
|
|
1050
|
-
]
|
|
1051
|
-
};
|
|
1052
|
-
};
|
|
1053
|
-
var createEditorAction = (id, props, invoke) => {
|
|
1054
|
-
const { label = [
|
|
1055
|
-
`${id} label`,
|
|
1056
|
-
{
|
|
1057
|
-
ns: translationKey
|
|
1058
|
-
}
|
|
1059
|
-
], ...rest } = props;
|
|
1060
|
-
return createMenuAction(id, invoke, {
|
|
1061
|
-
label,
|
|
1062
|
-
...rest
|
|
1063
|
-
});
|
|
1064
|
-
};
|
|
1065
|
-
var createEditorActionGroup = (id, props, icon) => {
|
|
1066
|
-
const { label = [
|
|
1067
|
-
`${id} label`,
|
|
1068
|
-
{
|
|
1069
|
-
ns: translationKey
|
|
1070
|
-
}
|
|
1071
|
-
], ...rest } = props;
|
|
1072
|
-
return createMenuItemGroup(id, {
|
|
1073
|
-
label,
|
|
1074
|
-
icon,
|
|
1075
|
-
iconOnly: true,
|
|
1076
|
-
...rest
|
|
1077
|
-
});
|
|
1078
|
-
};
|
|
1079
|
-
var createListGroupAction = (value) => createEditorActionGroup("list", {
|
|
1080
|
-
variant: "toggleGroup",
|
|
1081
|
-
selectCardinality: "single",
|
|
1082
|
-
value
|
|
1083
|
-
});
|
|
1084
|
-
var createListActions = (value, getView) => Object.entries(listStyles).map(([listStyle, icon]) => {
|
|
1085
|
-
const checked = value === listStyle;
|
|
1086
|
-
return createEditorAction(`list-${listStyle}`, {
|
|
1087
|
-
checked,
|
|
1088
|
-
icon
|
|
1089
|
-
}, () => {
|
|
1090
|
-
const view = getView();
|
|
1091
|
-
if (!view) {
|
|
1092
|
-
return;
|
|
1093
|
-
}
|
|
1094
|
-
const listType = listStyle === "ordered" ? List.Ordered : listStyle === "bullet" ? List.Bullet : List.Task;
|
|
1095
|
-
if (checked) {
|
|
1096
|
-
removeList(listType)(view);
|
|
1097
|
-
} else {
|
|
1098
|
-
addList(listType)(view);
|
|
1099
|
-
}
|
|
1100
|
-
});
|
|
1101
|
-
});
|
|
1034
|
+
import { Menu as Menu2, MenuBuilder, useMenuActions } from "@dxos/react-ui-menu";
|
|
1102
1035
|
|
|
1103
1036
|
// src/components/EditorToolbar/blocks.ts
|
|
1104
1037
|
import { addBlockquote, addCodeblock, insertTable, removeBlockquote, removeCodeblock } from "@dxos/ui-editor";
|
|
1105
|
-
var
|
|
1106
|
-
variant: "toggleGroup",
|
|
1107
|
-
selectCardinality: "single",
|
|
1108
|
-
value
|
|
1109
|
-
});
|
|
1110
|
-
var createBlockActions = (value, getView, blankLine) => Object.entries({
|
|
1038
|
+
var blockTypes = {
|
|
1111
1039
|
blockquote: "ph--quotes--regular",
|
|
1112
1040
|
codeblock: "ph--code-block--regular",
|
|
1113
1041
|
table: "ph--table--regular"
|
|
1114
|
-
}
|
|
1115
|
-
|
|
1116
|
-
return createEditorAction(type, {
|
|
1117
|
-
checked,
|
|
1118
|
-
...type === "table" && {
|
|
1119
|
-
disabled: !!blankLine
|
|
1120
|
-
},
|
|
1121
|
-
icon
|
|
1122
|
-
}, () => {
|
|
1123
|
-
const view = getView();
|
|
1124
|
-
if (!view) {
|
|
1125
|
-
return;
|
|
1126
|
-
}
|
|
1127
|
-
switch (type) {
|
|
1128
|
-
case "blockquote":
|
|
1129
|
-
checked ? removeBlockquote(view) : addBlockquote(view);
|
|
1130
|
-
break;
|
|
1131
|
-
case "codeblock":
|
|
1132
|
-
checked ? removeCodeblock(view) : addCodeblock(view);
|
|
1133
|
-
break;
|
|
1134
|
-
case "table":
|
|
1135
|
-
insertTable(view);
|
|
1136
|
-
break;
|
|
1137
|
-
}
|
|
1138
|
-
});
|
|
1139
|
-
});
|
|
1140
|
-
var createBlocks = (state, getView) => {
|
|
1042
|
+
};
|
|
1043
|
+
var addBlocks = (state, getView) => (builder) => {
|
|
1141
1044
|
const value = state?.blockQuote ? "blockquote" : state.blockType ?? "";
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
nodes: [
|
|
1146
|
-
blockGroupAction,
|
|
1147
|
-
...blockActions
|
|
1148
|
-
],
|
|
1149
|
-
edges: [
|
|
1045
|
+
builder.group("block", {
|
|
1046
|
+
label: [
|
|
1047
|
+
"block.label",
|
|
1150
1048
|
{
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1049
|
+
ns: translationKey
|
|
1050
|
+
}
|
|
1051
|
+
],
|
|
1052
|
+
iconOnly: true,
|
|
1053
|
+
variant: "toggleGroup",
|
|
1054
|
+
selectCardinality: "single",
|
|
1055
|
+
value
|
|
1056
|
+
}, (group) => {
|
|
1057
|
+
for (const [type, icon] of Object.entries(blockTypes)) {
|
|
1058
|
+
const checked = type === value;
|
|
1059
|
+
group.action(type, {
|
|
1060
|
+
label: [
|
|
1061
|
+
`block.${type}.label`,
|
|
1062
|
+
{
|
|
1063
|
+
ns: translationKey
|
|
1064
|
+
}
|
|
1065
|
+
],
|
|
1066
|
+
checked,
|
|
1067
|
+
...type === "table" && {
|
|
1068
|
+
disabled: !!state.blankLine
|
|
1069
|
+
},
|
|
1070
|
+
icon
|
|
1071
|
+
}, () => {
|
|
1072
|
+
const view = getView();
|
|
1073
|
+
if (!view) {
|
|
1074
|
+
return;
|
|
1075
|
+
}
|
|
1076
|
+
switch (type) {
|
|
1077
|
+
case "blockquote":
|
|
1078
|
+
checked ? removeBlockquote(view) : addBlockquote(view);
|
|
1079
|
+
break;
|
|
1080
|
+
case "codeblock":
|
|
1081
|
+
checked ? removeCodeblock(view) : addCodeblock(view);
|
|
1082
|
+
break;
|
|
1083
|
+
case "table":
|
|
1084
|
+
insertTable(view);
|
|
1085
|
+
break;
|
|
1086
|
+
}
|
|
1087
|
+
});
|
|
1088
|
+
}
|
|
1089
|
+
});
|
|
1160
1090
|
};
|
|
1161
1091
|
|
|
1162
1092
|
// src/components/EditorToolbar/formatting.ts
|
|
@@ -1168,201 +1098,222 @@ var formats = {
|
|
|
1168
1098
|
code: "ph--code--regular",
|
|
1169
1099
|
link: "ph--link--regular"
|
|
1170
1100
|
};
|
|
1171
|
-
var
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1101
|
+
var addFormatting = (state, getView) => (builder) => {
|
|
1102
|
+
const formatting = state;
|
|
1103
|
+
builder.group("formatting", {
|
|
1104
|
+
label: [
|
|
1105
|
+
"formatting.label",
|
|
1106
|
+
{
|
|
1107
|
+
ns: translationKey
|
|
1108
|
+
}
|
|
1109
|
+
],
|
|
1110
|
+
iconOnly: true,
|
|
1111
|
+
variant: "toggleGroup",
|
|
1112
|
+
selectCardinality: "multiple",
|
|
1113
|
+
value: Object.keys(formats).filter((key) => !!formatting[key])
|
|
1114
|
+
}, (group) => {
|
|
1115
|
+
for (const [type, icon] of Object.entries(formats)) {
|
|
1116
|
+
const checked = !!formatting[type];
|
|
1117
|
+
group.action(type, {
|
|
1118
|
+
label: [
|
|
1119
|
+
`formatting.${type}.label`,
|
|
1120
|
+
{
|
|
1121
|
+
ns: translationKey
|
|
1122
|
+
}
|
|
1123
|
+
],
|
|
1124
|
+
checked,
|
|
1125
|
+
icon
|
|
1126
|
+
}, () => {
|
|
1127
|
+
const view = getView();
|
|
1128
|
+
if (!view) {
|
|
1129
|
+
return;
|
|
1130
|
+
}
|
|
1131
|
+
if (type === "link") {
|
|
1132
|
+
checked ? removeLink(view) : addLink()(view);
|
|
1133
|
+
return;
|
|
1134
|
+
}
|
|
1135
|
+
setStyle(type === "strong" ? Inline.Strong : type === "emphasis" ? Inline.Emphasis : type === "strikethrough" ? Inline.Strikethrough : Inline.Code, !checked)(view);
|
|
1136
|
+
});
|
|
1189
1137
|
}
|
|
1190
|
-
const inlineType = type === "strong" ? Inline.Strong : type === "emphasis" ? Inline.Emphasis : type === "strikethrough" ? Inline.Strikethrough : Inline.Code;
|
|
1191
|
-
setStyle(inlineType, !checked)(view);
|
|
1192
1138
|
});
|
|
1193
|
-
});
|
|
1194
|
-
var createFormatting = (state, getView) => {
|
|
1195
|
-
const formattingGroupAction = createFormattingGroup(state);
|
|
1196
|
-
const formattingActions = createFormattingActions(state, getView);
|
|
1197
|
-
return {
|
|
1198
|
-
nodes: [
|
|
1199
|
-
formattingGroupAction,
|
|
1200
|
-
...formattingActions
|
|
1201
|
-
],
|
|
1202
|
-
edges: [
|
|
1203
|
-
{
|
|
1204
|
-
source: "root",
|
|
1205
|
-
target: "formatting"
|
|
1206
|
-
},
|
|
1207
|
-
...formattingActions.map(({ id }) => ({
|
|
1208
|
-
source: formattingGroupAction.id,
|
|
1209
|
-
target: id
|
|
1210
|
-
}))
|
|
1211
|
-
]
|
|
1212
|
-
};
|
|
1213
1139
|
};
|
|
1214
1140
|
|
|
1215
1141
|
// src/components/EditorToolbar/headings.ts
|
|
1216
1142
|
import { setHeading } from "@dxos/ui-editor";
|
|
1217
|
-
var
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
"1": "ph--text-h-one--regular",
|
|
1227
|
-
"2": "ph--text-h-two--regular",
|
|
1228
|
-
"3": "ph--text-h-three--regular",
|
|
1229
|
-
"4": "ph--text-h-four--regular",
|
|
1230
|
-
"5": "ph--text-h-five--regular",
|
|
1231
|
-
"6": "ph--text-h-six--regular"
|
|
1232
|
-
}).map(([levelStr, icon]) => {
|
|
1233
|
-
const level = parseInt(levelStr);
|
|
1234
|
-
return createEditorAction(`heading--${levelStr}`, {
|
|
1235
|
-
label: [
|
|
1236
|
-
"heading level label",
|
|
1237
|
-
{
|
|
1238
|
-
count: level,
|
|
1239
|
-
ns: translationKey
|
|
1240
|
-
}
|
|
1241
|
-
],
|
|
1242
|
-
icon,
|
|
1243
|
-
checked: levelStr === currentLevel
|
|
1244
|
-
}, () => setHeading(level)(getView()));
|
|
1245
|
-
});
|
|
1143
|
+
var headingIcons = {
|
|
1144
|
+
0: "ph--paragraph--regular",
|
|
1145
|
+
1: "ph--text-h-one--regular",
|
|
1146
|
+
2: "ph--text-h-two--regular",
|
|
1147
|
+
3: "ph--text-h-three--regular",
|
|
1148
|
+
4: "ph--text-h-four--regular",
|
|
1149
|
+
5: "ph--text-h-five--regular",
|
|
1150
|
+
6: "ph--text-h-six--regular"
|
|
1151
|
+
};
|
|
1246
1152
|
var computeHeadingValue = (state) => {
|
|
1247
1153
|
const blockType = state ? state.blockType : "paragraph";
|
|
1248
1154
|
const heading = blockType && /heading(\d)/.exec(blockType);
|
|
1249
1155
|
return heading ? heading[1] : blockType === "paragraph" || !blockType ? "0" : "";
|
|
1250
1156
|
};
|
|
1251
|
-
var
|
|
1157
|
+
var addHeadings = (state, getView) => (builder) => {
|
|
1252
1158
|
const headingValue = computeHeadingValue(state);
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
nodes: [
|
|
1257
|
-
headingGroupAction,
|
|
1258
|
-
...headingActions
|
|
1259
|
-
],
|
|
1260
|
-
edges: [
|
|
1159
|
+
builder.group("heading", {
|
|
1160
|
+
label: [
|
|
1161
|
+
"heading.label",
|
|
1261
1162
|
{
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1163
|
+
ns: translationKey
|
|
1164
|
+
}
|
|
1165
|
+
],
|
|
1166
|
+
icon: "ph--text-h--regular",
|
|
1167
|
+
iconOnly: true,
|
|
1168
|
+
variant: "dropdownMenu",
|
|
1169
|
+
applyActive: true,
|
|
1170
|
+
selectCardinality: "single",
|
|
1171
|
+
// TODO(wittjosiah): Remove? Not sure this does anything.
|
|
1172
|
+
value: headingValue
|
|
1173
|
+
}, (group) => {
|
|
1174
|
+
for (const [levelStr, icon] of Object.entries(headingIcons)) {
|
|
1175
|
+
const level = parseInt(levelStr);
|
|
1176
|
+
group.action(`heading--${levelStr}`, {
|
|
1177
|
+
label: [
|
|
1178
|
+
"heading-level.label",
|
|
1179
|
+
{
|
|
1180
|
+
count: level,
|
|
1181
|
+
ns: translationKey
|
|
1182
|
+
}
|
|
1183
|
+
],
|
|
1184
|
+
icon,
|
|
1185
|
+
checked: levelStr === headingValue
|
|
1186
|
+
}, () => setHeading(level)(getView()));
|
|
1187
|
+
}
|
|
1188
|
+
});
|
|
1271
1189
|
};
|
|
1272
1190
|
|
|
1273
1191
|
// src/components/EditorToolbar/image.ts
|
|
1274
|
-
var
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1192
|
+
var addImageUpload = (onImageUpload) => (builder) => {
|
|
1193
|
+
builder.action("image", {
|
|
1194
|
+
label: [
|
|
1195
|
+
"image.label",
|
|
1196
|
+
{
|
|
1197
|
+
ns: translationKey
|
|
1198
|
+
}
|
|
1199
|
+
],
|
|
1200
|
+
testId: "editor.toolbar.image",
|
|
1201
|
+
icon: "ph--image-square--regular"
|
|
1202
|
+
}, onImageUpload);
|
|
1203
|
+
};
|
|
1204
|
+
|
|
1205
|
+
// src/components/EditorToolbar/lists.ts
|
|
1206
|
+
import { List, addList, removeList } from "@dxos/ui-editor";
|
|
1207
|
+
var listStyles = {
|
|
1208
|
+
bullet: "ph--list-bullets--regular",
|
|
1209
|
+
ordered: "ph--list-numbers--regular",
|
|
1210
|
+
task: "ph--list-checks--regular"
|
|
1211
|
+
};
|
|
1212
|
+
var addLists = (state, getView) => (builder) => {
|
|
1213
|
+
const value = state.listStyle ?? "";
|
|
1214
|
+
builder.group("list", {
|
|
1215
|
+
label: [
|
|
1216
|
+
"list.label",
|
|
1217
|
+
{
|
|
1218
|
+
ns: translationKey
|
|
1219
|
+
}
|
|
1220
|
+
],
|
|
1221
|
+
iconOnly: true,
|
|
1222
|
+
variant: "toggleGroup",
|
|
1223
|
+
selectCardinality: "single",
|
|
1224
|
+
value
|
|
1225
|
+
}, (group) => {
|
|
1226
|
+
for (const [listStyle, icon] of Object.entries(listStyles)) {
|
|
1227
|
+
const checked = value === listStyle;
|
|
1228
|
+
group.action(`list-${listStyle}`, {
|
|
1229
|
+
label: [
|
|
1230
|
+
`list.${listStyle}.label`,
|
|
1231
|
+
{
|
|
1232
|
+
ns: translationKey
|
|
1233
|
+
}
|
|
1234
|
+
],
|
|
1235
|
+
checked,
|
|
1236
|
+
icon
|
|
1237
|
+
}, () => {
|
|
1238
|
+
const view = getView();
|
|
1239
|
+
if (!view) {
|
|
1240
|
+
return;
|
|
1241
|
+
}
|
|
1242
|
+
const listType = listStyle === "ordered" ? List.Ordered : listStyle === "bullet" ? List.Bullet : List.Task;
|
|
1243
|
+
if (checked) {
|
|
1244
|
+
removeList(listType)(view);
|
|
1245
|
+
} else {
|
|
1246
|
+
addList(listType)(view);
|
|
1247
|
+
}
|
|
1248
|
+
});
|
|
1286
1249
|
}
|
|
1287
|
-
|
|
1288
|
-
}
|
|
1250
|
+
});
|
|
1251
|
+
};
|
|
1289
1252
|
|
|
1290
1253
|
// src/components/EditorToolbar/search.ts
|
|
1291
1254
|
import { openSearchPanel } from "@codemirror/search";
|
|
1292
|
-
var
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
}
|
|
1305
|
-
]
|
|
1306
|
-
});
|
|
1255
|
+
var addSearch = (getView) => (builder) => {
|
|
1256
|
+
builder.action("search", {
|
|
1257
|
+
label: [
|
|
1258
|
+
"search.label",
|
|
1259
|
+
{
|
|
1260
|
+
ns: translationKey
|
|
1261
|
+
}
|
|
1262
|
+
],
|
|
1263
|
+
testId: "editor.toolbar.search",
|
|
1264
|
+
icon: "ph--magnifying-glass--regular"
|
|
1265
|
+
}, () => openSearchPanel(getView()));
|
|
1266
|
+
};
|
|
1307
1267
|
|
|
1308
1268
|
// src/components/EditorToolbar/view-mode.ts
|
|
1309
|
-
var
|
|
1310
|
-
variant: "dropdownMenu",
|
|
1311
|
-
applyActive: true,
|
|
1312
|
-
selectCardinality: "single",
|
|
1313
|
-
value
|
|
1314
|
-
}, "ph--eye--regular");
|
|
1315
|
-
var createViewModeActions = (value, onViewModeChange) => Object.entries({
|
|
1269
|
+
var viewModes = {
|
|
1316
1270
|
preview: "ph--eye--regular",
|
|
1317
1271
|
source: "ph--pencil-simple--regular",
|
|
1318
1272
|
readonly: "ph--pencil-slash--regular"
|
|
1319
|
-
}
|
|
1320
|
-
|
|
1321
|
-
|
|
1273
|
+
};
|
|
1274
|
+
var addViewMode = (state, onViewModeChange) => (builder) => {
|
|
1275
|
+
const value = state.viewMode ?? "source";
|
|
1276
|
+
builder.group("viewMode", {
|
|
1322
1277
|
label: [
|
|
1323
|
-
|
|
1278
|
+
"view-mode.label",
|
|
1324
1279
|
{
|
|
1325
1280
|
ns: translationKey
|
|
1326
1281
|
}
|
|
1327
1282
|
],
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
}))
|
|
1350
|
-
]
|
|
1351
|
-
};
|
|
1283
|
+
icon: "ph--eye--regular",
|
|
1284
|
+
iconOnly: true,
|
|
1285
|
+
variant: "dropdownMenu",
|
|
1286
|
+
applyActive: true,
|
|
1287
|
+
selectCardinality: "single",
|
|
1288
|
+
value
|
|
1289
|
+
}, (group) => {
|
|
1290
|
+
for (const [viewMode, icon] of Object.entries(viewModes)) {
|
|
1291
|
+
const checked = viewMode === value;
|
|
1292
|
+
group.action(`view-mode--${viewMode}`, {
|
|
1293
|
+
label: [
|
|
1294
|
+
`view-mode.${viewMode}.label`,
|
|
1295
|
+
{
|
|
1296
|
+
ns: translationKey
|
|
1297
|
+
}
|
|
1298
|
+
],
|
|
1299
|
+
checked,
|
|
1300
|
+
icon
|
|
1301
|
+
}, () => onViewModeChange(viewMode));
|
|
1302
|
+
}
|
|
1303
|
+
});
|
|
1352
1304
|
};
|
|
1353
1305
|
|
|
1354
1306
|
// src/components/EditorToolbar/EditorToolbar.tsx
|
|
1355
1307
|
var EditorToolbar = /* @__PURE__ */ memo(({ classNames, role, attendableId, onAction, ...props }) => {
|
|
1356
|
-
const
|
|
1308
|
+
const menuActions = useEditorToolbarActionGraph(props);
|
|
1357
1309
|
return /* @__PURE__ */ React3.createElement(ElevationProvider, {
|
|
1358
1310
|
elevation: role === "section" ? "positioned" : "base"
|
|
1359
|
-
}, /* @__PURE__ */ React3.createElement(
|
|
1360
|
-
...
|
|
1311
|
+
}, /* @__PURE__ */ React3.createElement(Menu2.Root, {
|
|
1312
|
+
...menuActions,
|
|
1361
1313
|
attendableId,
|
|
1362
1314
|
onAction
|
|
1363
|
-
}, /* @__PURE__ */ React3.createElement(
|
|
1364
|
-
classNames
|
|
1365
|
-
textBlockWidth: true
|
|
1315
|
+
}, /* @__PURE__ */ React3.createElement(Menu2.Toolbar, {
|
|
1316
|
+
classNames
|
|
1366
1317
|
})));
|
|
1367
1318
|
});
|
|
1368
1319
|
var useEditorToolbarActionGraph = ({ state, getView, customActions, ...features }) => {
|
|
@@ -1387,41 +1338,8 @@ var useEditorToolbarActionGraph = ({ state, getView, customActions, ...features
|
|
|
1387
1338
|
};
|
|
1388
1339
|
var createToolbarActions = ({ state, getView, customActions, ...features }) => {
|
|
1389
1340
|
return Atom.make((get) => {
|
|
1390
|
-
const graph = {
|
|
1391
|
-
nodes: [],
|
|
1392
|
-
edges: []
|
|
1393
|
-
};
|
|
1394
|
-
const addSubGraph = (graph2, subGraph) => {
|
|
1395
|
-
graph2.nodes.push(...subGraph.nodes);
|
|
1396
|
-
graph2.edges.push(...subGraph.edges);
|
|
1397
|
-
};
|
|
1398
1341
|
const stateSnapshot = get(state);
|
|
1399
|
-
|
|
1400
|
-
addSubGraph(graph, createHeadings(stateSnapshot, getView));
|
|
1401
|
-
}
|
|
1402
|
-
if (features?.showFormatting ?? true) {
|
|
1403
|
-
addSubGraph(graph, createFormatting(stateSnapshot, getView));
|
|
1404
|
-
}
|
|
1405
|
-
if (features?.showLists ?? true) {
|
|
1406
|
-
addSubGraph(graph, createLists(stateSnapshot, getView));
|
|
1407
|
-
}
|
|
1408
|
-
if (features?.showBlocks ?? true) {
|
|
1409
|
-
addSubGraph(graph, createBlocks(stateSnapshot, getView));
|
|
1410
|
-
}
|
|
1411
|
-
if (features?.onImageUpload) {
|
|
1412
|
-
addSubGraph(graph, createImageUpload(features.onImageUpload));
|
|
1413
|
-
}
|
|
1414
|
-
addSubGraph(graph, createGapSeparator());
|
|
1415
|
-
if (customActions) {
|
|
1416
|
-
addSubGraph(graph, get(customActions));
|
|
1417
|
-
}
|
|
1418
|
-
if (features?.showSearch ?? true) {
|
|
1419
|
-
addSubGraph(graph, createSearch(getView));
|
|
1420
|
-
}
|
|
1421
|
-
if (features?.onViewModeChange) {
|
|
1422
|
-
addSubGraph(graph, createViewMode(stateSnapshot, features.onViewModeChange));
|
|
1423
|
-
}
|
|
1424
|
-
return graph;
|
|
1342
|
+
return MenuBuilder.make().subgraph(features?.showHeadings !== false && addHeadings(stateSnapshot, getView)).subgraph(features?.showFormatting !== false && addFormatting(stateSnapshot, getView)).subgraph(features?.showLists !== false && addLists(stateSnapshot, getView)).subgraph(features?.showBlocks !== false && addBlocks(stateSnapshot, getView)).subgraph(features?.onImageUpload && addImageUpload(features.onImageUpload)).separator("gap").subgraph(customActions && get(customActions)).subgraph(features?.showSearch !== false && addSearch(getView)).subgraph(features?.onViewModeChange && addViewMode(stateSnapshot, features.onViewModeChange)).build();
|
|
1425
1343
|
});
|
|
1426
1344
|
};
|
|
1427
1345
|
|
|
@@ -1463,15 +1381,17 @@ var EditorRoot = /* @__PURE__ */ forwardRef2(({ children, extensions: extensions
|
|
|
1463
1381
|
}, children));
|
|
1464
1382
|
});
|
|
1465
1383
|
EditorRoot.displayName = "Editor.Root";
|
|
1384
|
+
var EDITOR_VIEWPORT_NAME = "Editor.Viewport";
|
|
1466
1385
|
var EditorViewport = ({ classNames, children }) => {
|
|
1467
1386
|
return /* @__PURE__ */ React4.createElement("div", {
|
|
1468
1387
|
role: "none",
|
|
1469
|
-
className: mx2("grid grid-rows-[min-content_1fr]
|
|
1388
|
+
className: mx2("grid grid-rows-[min-content_1fr] h-full overflow-hidden", classNames)
|
|
1470
1389
|
}, children);
|
|
1471
1390
|
};
|
|
1472
|
-
EditorViewport.displayName =
|
|
1391
|
+
EditorViewport.displayName = EDITOR_VIEWPORT_NAME;
|
|
1392
|
+
var EDITOR_CONTENT_NAME = "Editor.Content";
|
|
1473
1393
|
var EditorContent2 = ({ extensions: providedExtensions, ...props }) => {
|
|
1474
|
-
const { extensions: additionalExtensions = [], setController } = useEditorContext(
|
|
1394
|
+
const { extensions: additionalExtensions = [], setController } = useEditorContext(EDITOR_CONTENT_NAME);
|
|
1475
1395
|
const extensions = useMemo5(() => [
|
|
1476
1396
|
additionalExtensions,
|
|
1477
1397
|
providedExtensions
|
|
@@ -1485,13 +1405,14 @@ var EditorContent2 = ({ extensions: providedExtensions, ...props }) => {
|
|
|
1485
1405
|
ref: setController
|
|
1486
1406
|
});
|
|
1487
1407
|
};
|
|
1488
|
-
EditorContent2.displayName =
|
|
1408
|
+
EditorContent2.displayName = EDITOR_CONTENT_NAME;
|
|
1409
|
+
var EDITOR_TOOLBAR_NAME = "Editor.Toolbar";
|
|
1489
1410
|
var EditorToolbar2 = (props) => {
|
|
1490
|
-
const { controller, state } = useEditorContext(
|
|
1411
|
+
const { controller, state } = useEditorContext(EDITOR_TOOLBAR_NAME);
|
|
1491
1412
|
const getView = useCallback4(() => {
|
|
1492
1413
|
invariant3(controller?.view, void 0, {
|
|
1493
1414
|
F: __dxlog_file4,
|
|
1494
|
-
L:
|
|
1415
|
+
L: 153,
|
|
1495
1416
|
S: void 0,
|
|
1496
1417
|
A: [
|
|
1497
1418
|
"controller?.view",
|
|
@@ -1508,7 +1429,7 @@ var EditorToolbar2 = (props) => {
|
|
|
1508
1429
|
state
|
|
1509
1430
|
});
|
|
1510
1431
|
};
|
|
1511
|
-
EditorToolbar2.displayName =
|
|
1432
|
+
EditorToolbar2.displayName = EDITOR_TOOLBAR_NAME;
|
|
1512
1433
|
var Editor = {
|
|
1513
1434
|
Root: EditorRoot,
|
|
1514
1435
|
Viewport: EditorViewport,
|
|
@@ -1527,20 +1448,20 @@ var EditorPreviewProvider = ({ children, onLookup }) => {
|
|
|
1527
1448
|
const [value, setValue] = useState5({});
|
|
1528
1449
|
const [open, setOpen] = useState5(false);
|
|
1529
1450
|
const handleActivate = useCallback5((event) => {
|
|
1530
|
-
const {
|
|
1451
|
+
const { dxn, label, trigger } = event;
|
|
1531
1452
|
setValue((value2) => ({
|
|
1532
1453
|
...value2,
|
|
1533
1454
|
link: {
|
|
1534
1455
|
label,
|
|
1535
|
-
|
|
1456
|
+
dxn
|
|
1536
1457
|
},
|
|
1537
1458
|
pending: true
|
|
1538
1459
|
}));
|
|
1539
|
-
triggerRef.current =
|
|
1460
|
+
triggerRef.current = trigger;
|
|
1540
1461
|
queueMicrotask(() => setOpen(true));
|
|
1541
1462
|
void onLookup?.({
|
|
1542
1463
|
label,
|
|
1543
|
-
|
|
1464
|
+
dxn
|
|
1544
1465
|
}).then((target) => setValue((value2) => ({
|
|
1545
1466
|
...value2,
|
|
1546
1467
|
target: target ?? void 0,
|
|
@@ -1572,9 +1493,9 @@ var EditorPreviewProvider = ({ children, onLookup }) => {
|
|
|
1572
1493
|
}, /* @__PURE__ */ React5.createElement(Popover2.VirtualTrigger, {
|
|
1573
1494
|
virtualRef: triggerRef
|
|
1574
1495
|
}), /* @__PURE__ */ React5.createElement("div", {
|
|
1575
|
-
ref: setRoot,
|
|
1576
1496
|
role: "none",
|
|
1577
|
-
className: "contents"
|
|
1497
|
+
className: "contents",
|
|
1498
|
+
ref: setRoot
|
|
1578
1499
|
}, children)));
|
|
1579
1500
|
};
|
|
1580
1501
|
export {
|
|
@@ -1595,6 +1516,7 @@ export {
|
|
|
1595
1516
|
popoverRangeEffect,
|
|
1596
1517
|
popoverStateField,
|
|
1597
1518
|
translations,
|
|
1519
|
+
useEditorContext,
|
|
1598
1520
|
useEditorMenu,
|
|
1599
1521
|
useEditorPreview,
|
|
1600
1522
|
useEditorToolbar,
|