@dxos/react-ui-editor 0.4.3-main.c3bfede → 0.4.3-main.d01b40e
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 +157 -118
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/types/src/components/TextEditor/MarkdownEditor.stories.d.ts +6 -3
- package/dist/types/src/components/TextEditor/MarkdownEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/TextEditor/TextEditor.d.ts +0 -3
- package/dist/types/src/components/TextEditor/TextEditor.d.ts.map +1 -1
- package/dist/types/src/components/TextEditor/TextEditor.stories.d.ts +3 -3
- package/dist/types/src/components/TextEditor/automerge.stories.d.ts +3 -3
- package/dist/types/src/components/TextEditor/hooks.stories.d.ts +3 -3
- package/dist/types/src/components/Toolbar/Toolbar.d.ts +1 -1
- package/dist/types/src/components/Toolbar/Toolbar.d.ts.map +1 -1
- package/dist/types/src/components/Toolbar/Toolbar.stories.d.ts +3 -3
- package/dist/types/src/extensions/comments.d.ts.map +1 -1
- package/dist/types/src/extensions/index.d.ts +1 -0
- package/dist/types/src/extensions/index.d.ts.map +1 -1
- package/dist/types/src/extensions/markdown/formatting.d.ts.map +1 -1
- package/dist/types/src/extensions/modes.d.ts +11 -0
- package/dist/types/src/extensions/modes.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +2 -2
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +3 -3
- package/package.json +25 -25
- package/src/components/TextEditor/MarkdownEditor.stories.tsx +10 -1
- package/src/components/TextEditor/TextEditor.tsx +29 -50
- package/src/components/Toolbar/Toolbar.tsx +81 -69
- package/src/extensions/comments.ts +5 -2
- package/src/extensions/index.ts +1 -0
- package/src/extensions/markdown/formatting.test.ts +1 -1
- package/src/extensions/markdown/formatting.ts +5 -2
- package/src/extensions/modes.ts +36 -0
- package/src/hooks/useActionHandler.ts +1 -1
- package/src/index.ts +3 -2
- package/src/translations.ts +3 -3
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// packages/ui/react-ui-editor/src/index.ts
|
|
2
|
+
import { keymap as keymap8 } from "@codemirror/view";
|
|
2
3
|
import { TextKind } from "@dxos/protocols/proto/dxos/echo/model/text";
|
|
3
4
|
import { Doc, YText, YXmlFragment } from "@dxos/text-model";
|
|
4
|
-
import { keymap as keymap7 } from "@codemirror/view";
|
|
5
5
|
|
|
6
6
|
// packages/ui/react-ui-editor/src/components/TextEditor/index.ts
|
|
7
7
|
import { tags as tags2 } from "@lezer/highlight";
|
|
@@ -9,7 +9,7 @@ import { tags as tags2 } from "@lezer/highlight";
|
|
|
9
9
|
// packages/ui/react-ui-editor/src/components/TextEditor/TextEditor.tsx
|
|
10
10
|
import { EditorState as EditorState2 } from "@codemirror/state";
|
|
11
11
|
import { EditorView as EditorView15 } from "@codemirror/view";
|
|
12
|
-
import {
|
|
12
|
+
import { useFocusableGroup } from "@fluentui/react-tabster";
|
|
13
13
|
import defaultsDeep2 from "lodash.defaultsdeep";
|
|
14
14
|
import React, { forwardRef, useCallback, useEffect as useEffect2, useImperativeHandle, useRef, useState as useState2 } from "react";
|
|
15
15
|
import { log as log2 } from "@dxos/log";
|
|
@@ -1152,10 +1152,16 @@ var styles3 = EditorView6.baseTheme({
|
|
|
1152
1152
|
}
|
|
1153
1153
|
});
|
|
1154
1154
|
var commentMark = Decoration3.mark({
|
|
1155
|
-
class: "cm-comment"
|
|
1155
|
+
class: "cm-comment",
|
|
1156
|
+
attributes: {
|
|
1157
|
+
"data-testid": "cm-comment"
|
|
1158
|
+
}
|
|
1156
1159
|
});
|
|
1157
1160
|
var commentCurrentMark = Decoration3.mark({
|
|
1158
|
-
class: "cm-comment-current"
|
|
1161
|
+
class: "cm-comment-current",
|
|
1162
|
+
attributes: {
|
|
1163
|
+
"data-testid": "cm-comment"
|
|
1164
|
+
}
|
|
1159
1165
|
});
|
|
1160
1166
|
var focusComment = (view, id, center = true) => {
|
|
1161
1167
|
const comment = view.state.field(commentsState).comments.find((range2) => range2.comment.id === id);
|
|
@@ -2171,7 +2177,6 @@ var snippets = {
|
|
|
2171
2177
|
codeblock: snippet([
|
|
2172
2178
|
//
|
|
2173
2179
|
"```#{}",
|
|
2174
|
-
"#{}",
|
|
2175
2180
|
"```"
|
|
2176
2181
|
].join("\n")),
|
|
2177
2182
|
table: snippet([
|
|
@@ -2376,13 +2381,17 @@ var addList = (type) => ({ state, dispatch }) => {
|
|
|
2376
2381
|
if (!blocks.length) {
|
|
2377
2382
|
const { from, to } = state.doc.lineAt(state.selection.main.anchor);
|
|
2378
2383
|
if (from === to) {
|
|
2384
|
+
const insert = type === 1 ? "- " : type === 0 ? "1. " : "- [ ] ";
|
|
2379
2385
|
dispatch(state.update({
|
|
2380
2386
|
changes: [
|
|
2381
2387
|
{
|
|
2382
2388
|
from,
|
|
2383
|
-
insert
|
|
2389
|
+
insert
|
|
2384
2390
|
}
|
|
2385
2391
|
],
|
|
2392
|
+
selection: {
|
|
2393
|
+
anchor: from + insert.length
|
|
2394
|
+
},
|
|
2386
2395
|
userEvent: "format.list.add",
|
|
2387
2396
|
scrollIntoView: true
|
|
2388
2397
|
}));
|
|
@@ -3517,13 +3526,42 @@ var mention = ({ onSearch }) => {
|
|
|
3517
3526
|
});
|
|
3518
3527
|
};
|
|
3519
3528
|
|
|
3529
|
+
// packages/ui/react-ui-editor/src/extensions/modes.ts
|
|
3530
|
+
import { Facet as Facet4 } from "@codemirror/state";
|
|
3531
|
+
import { keymap as keymap6 } from "@codemirror/view";
|
|
3532
|
+
import { vim } from "@replit/codemirror-vim";
|
|
3533
|
+
var editorMode = Facet4.define({
|
|
3534
|
+
combine: (modes) => modes[0] ?? {}
|
|
3535
|
+
});
|
|
3536
|
+
var EditorModes = {
|
|
3537
|
+
default: [],
|
|
3538
|
+
vim: [
|
|
3539
|
+
vim(),
|
|
3540
|
+
editorMode.of({
|
|
3541
|
+
type: "vim",
|
|
3542
|
+
noTabster: true
|
|
3543
|
+
}),
|
|
3544
|
+
keymap6.of([
|
|
3545
|
+
{
|
|
3546
|
+
key: "Alt-Escape",
|
|
3547
|
+
run: (view) => {
|
|
3548
|
+
view.dispatch({
|
|
3549
|
+
userEvent: "focus.container"
|
|
3550
|
+
});
|
|
3551
|
+
return true;
|
|
3552
|
+
}
|
|
3553
|
+
}
|
|
3554
|
+
])
|
|
3555
|
+
]
|
|
3556
|
+
};
|
|
3557
|
+
|
|
3520
3558
|
// packages/ui/react-ui-editor/src/extensions/outliner.ts
|
|
3521
3559
|
var outliner = (options = {}) => {
|
|
3522
3560
|
return [];
|
|
3523
3561
|
};
|
|
3524
3562
|
|
|
3525
3563
|
// packages/ui/react-ui-editor/src/extensions/typewriter.ts
|
|
3526
|
-
import { keymap as
|
|
3564
|
+
import { keymap as keymap7 } from "@codemirror/view";
|
|
3527
3565
|
var defaultItems = [
|
|
3528
3566
|
"hello world!",
|
|
3529
3567
|
"this is a test.",
|
|
@@ -3533,7 +3571,7 @@ var typewriter = ({ delay = 75, items = defaultItems } = {}) => {
|
|
|
3533
3571
|
let t;
|
|
3534
3572
|
let idx = 0;
|
|
3535
3573
|
return [
|
|
3536
|
-
|
|
3574
|
+
keymap7.of([
|
|
3537
3575
|
{
|
|
3538
3576
|
// Reset.
|
|
3539
3577
|
key: "alt-meta-'",
|
|
@@ -3821,11 +3859,10 @@ var codeTheme = {
|
|
|
3821
3859
|
|
|
3822
3860
|
// packages/ui/react-ui-editor/src/components/TextEditor/TextEditor.tsx
|
|
3823
3861
|
var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-editor/src/components/TextEditor/TextEditor.tsx";
|
|
3824
|
-
var
|
|
3825
|
-
|
|
3826
|
-
|
|
3827
|
-
|
|
3828
|
-
var BaseTextEditor = /* @__PURE__ */ forwardRef(({ model, readonly, autoFocus, scrollTo, selection, editorMode, theme, slots = defaultSlots, extensions = [], debug }, forwardedRef) => {
|
|
3862
|
+
var BaseTextEditor = /* @__PURE__ */ forwardRef(({ model, readonly, autoFocus, scrollTo, selection, theme, slots = defaultSlots, extensions = [], debug }, forwardedRef) => {
|
|
3863
|
+
const tabsterDOMAttribute = useFocusableGroup({
|
|
3864
|
+
tabBehavior: "limited"
|
|
3865
|
+
});
|
|
3829
3866
|
const { themeMode } = useThemeContext();
|
|
3830
3867
|
const rootRef = useRef(null);
|
|
3831
3868
|
const [view, setView] = useState2(null);
|
|
@@ -3860,7 +3897,7 @@ var BaseTextEditor = /* @__PURE__ */ forwardRef(({ model, readonly, autoFocus, s
|
|
|
3860
3897
|
EditorView15.exceptionSink.of((err) => {
|
|
3861
3898
|
log2.catch(err, void 0, {
|
|
3862
3899
|
F: __dxlog_file3,
|
|
3863
|
-
L:
|
|
3900
|
+
L: 112,
|
|
3864
3901
|
S: void 0,
|
|
3865
3902
|
C: (f, a) => f(...a)
|
|
3866
3903
|
});
|
|
@@ -3876,14 +3913,20 @@ var BaseTextEditor = /* @__PURE__ */ forwardRef(({ model, readonly, autoFocus, s
|
|
|
3876
3913
|
EditorView15.contentAttributes.of({
|
|
3877
3914
|
class: slots.content?.className ?? ""
|
|
3878
3915
|
}),
|
|
3916
|
+
// Focus.
|
|
3917
|
+
EditorView15.updateListener.of((update2) => {
|
|
3918
|
+
update2.transactions.forEach((transaction) => {
|
|
3919
|
+
if (transaction.isUserEvent("focus.container")) {
|
|
3920
|
+
rootRef.current?.focus();
|
|
3921
|
+
}
|
|
3922
|
+
});
|
|
3923
|
+
}),
|
|
3879
3924
|
// State.
|
|
3880
3925
|
EditorView15.editable.of(!readonly),
|
|
3881
3926
|
EditorState2.readOnly.of(!!readonly),
|
|
3882
3927
|
// Storage and replication.
|
|
3883
3928
|
// NOTE: This must come before user extensions.
|
|
3884
3929
|
model.extension,
|
|
3885
|
-
// TODO(burdon): Factor out? (Requires special handling for Escape/Enter below).
|
|
3886
|
-
editorMode === "vim" && vim(),
|
|
3887
3930
|
// Custom.
|
|
3888
3931
|
...extensions
|
|
3889
3932
|
].filter(isNotFalsy4)
|
|
@@ -3903,6 +3946,9 @@ var BaseTextEditor = /* @__PURE__ */ forwardRef(({ model, readonly, autoFocus, s
|
|
|
3903
3946
|
});
|
|
3904
3947
|
view?.destroy();
|
|
3905
3948
|
setView(newView);
|
|
3949
|
+
if (state.facet(editorMode).noTabster) {
|
|
3950
|
+
rootRef.current.removeAttribute("data-tabster");
|
|
3951
|
+
}
|
|
3906
3952
|
return () => {
|
|
3907
3953
|
newView?.destroy();
|
|
3908
3954
|
setView(null);
|
|
@@ -3911,35 +3957,27 @@ var BaseTextEditor = /* @__PURE__ */ forwardRef(({ model, readonly, autoFocus, s
|
|
|
3911
3957
|
rootRef,
|
|
3912
3958
|
model,
|
|
3913
3959
|
readonly,
|
|
3914
|
-
editorMode,
|
|
3915
3960
|
themeMode
|
|
3916
3961
|
]);
|
|
3917
3962
|
const handleKeyUp = useCallback((event) => {
|
|
3918
|
-
const { key
|
|
3963
|
+
const { key } = event;
|
|
3919
3964
|
switch (key) {
|
|
3920
3965
|
case "Enter": {
|
|
3921
3966
|
view?.focus();
|
|
3922
3967
|
break;
|
|
3923
3968
|
}
|
|
3924
|
-
case "Escape": {
|
|
3925
|
-
if (editorMode === "vim" && (altKey || shiftKey || metaKey || ctrlKey)) {
|
|
3926
|
-
view?.focus();
|
|
3927
|
-
}
|
|
3928
|
-
break;
|
|
3929
|
-
}
|
|
3930
3969
|
}
|
|
3931
3970
|
}, [
|
|
3932
|
-
view
|
|
3933
|
-
editorMode
|
|
3971
|
+
view
|
|
3934
3972
|
]);
|
|
3935
3973
|
return /* @__PURE__ */ React.createElement("div", {
|
|
3936
|
-
key: model.id,
|
|
3937
3974
|
role: "none",
|
|
3975
|
+
ref: rootRef,
|
|
3976
|
+
key: model.id,
|
|
3938
3977
|
tabIndex: 0,
|
|
3939
|
-
...slots.root,
|
|
3940
|
-
// {...(editorMode !== 'vim' && tabsterDOMAttribute)}
|
|
3941
3978
|
onKeyUp: handleKeyUp,
|
|
3942
|
-
|
|
3979
|
+
...slots.root,
|
|
3980
|
+
...tabsterDOMAttribute
|
|
3943
3981
|
});
|
|
3944
3982
|
});
|
|
3945
3983
|
var TextEditor = /* @__PURE__ */ forwardRef(({ readonly, placeholder: placeholder3, lineWrapping, theme = textTheme, slots, extensions = [], ...props }, forwardedRef) => {
|
|
@@ -3995,7 +4033,7 @@ var defaultMarkdownSlots = {
|
|
|
3995
4033
|
};
|
|
3996
4034
|
|
|
3997
4035
|
// packages/ui/react-ui-editor/src/components/Toolbar/Toolbar.tsx
|
|
3998
|
-
import { ChatText, Code, CodeBlock, Link, ListBullets, ListChecks, ListNumbers, Paragraph, TextStrikethrough, Table as Table2, TextB, TextHOne, TextHTwo, TextHThree, TextHFour, TextHFive, TextHSix, TextItalic, Quotes
|
|
4036
|
+
import { ChatText, Code, CodeBlock, Link, ListBullets, ListChecks, ListNumbers, Paragraph, TextStrikethrough, Table as Table2, TextB, TextHOne, TextHTwo, TextHThree, TextHFour, TextHFive, TextHSix, TextItalic, Quotes } from "@phosphor-icons/react";
|
|
3999
4037
|
import { createContext } from "@radix-ui/react-context";
|
|
4000
4038
|
import React2 from "react";
|
|
4001
4039
|
import { DensityProvider, ElevationProvider, Select, Toolbar as NaturalToolbar, useTranslation } from "@dxos/react-ui";
|
|
@@ -4011,9 +4049,9 @@ var translations_default = [
|
|
|
4011
4049
|
"emphasis label": "Emphasis",
|
|
4012
4050
|
"strikethrough label": "Strike-through",
|
|
4013
4051
|
"code label": "Code",
|
|
4014
|
-
"bullet label": "Bullet list",
|
|
4015
|
-
"ordered label": "Numbered list",
|
|
4016
|
-
"task label": "Task list",
|
|
4052
|
+
"list-bullet label": "Bullet list",
|
|
4053
|
+
"list-ordered label": "Numbered list",
|
|
4054
|
+
"list-task label": "Task list",
|
|
4017
4055
|
"blockquote label": "Block quote",
|
|
4018
4056
|
"codeblock label": "Code block",
|
|
4019
4057
|
"comment label": "Create comment",
|
|
@@ -4050,7 +4088,7 @@ var ToolbarRoot = ({ children, onAction, classNames, state }) => {
|
|
|
4050
4088
|
}, children))));
|
|
4051
4089
|
};
|
|
4052
4090
|
var buttonStyles = "min-bs-0 p-2";
|
|
4053
|
-
var iconStyles = getSize(
|
|
4091
|
+
var iconStyles = getSize(5);
|
|
4054
4092
|
var ToolbarButton = ({ Icon, children, ...props }) => {
|
|
4055
4093
|
return /* @__PURE__ */ React2.createElement(NaturalToolbar.ToggleGroupItem, {
|
|
4056
4094
|
variant: "ghost",
|
|
@@ -4067,7 +4105,6 @@ var ToolbarSeparator = () => /* @__PURE__ */ React2.createElement("div", {
|
|
|
4067
4105
|
className: "grow"
|
|
4068
4106
|
});
|
|
4069
4107
|
var MarkdownHeading = () => {
|
|
4070
|
-
const { t } = useTranslation(translationKey);
|
|
4071
4108
|
const { onAction, state } = useToolbarContext("MarkdownFormatting");
|
|
4072
4109
|
const blockType = state ? state.blockType : "paragraph";
|
|
4073
4110
|
const header = blockType && /heading(\d)/.exec(blockType);
|
|
@@ -4080,21 +4117,13 @@ var MarkdownHeading = () => {
|
|
|
4080
4117
|
type: "heading",
|
|
4081
4118
|
data: parseInt(value2)
|
|
4082
4119
|
})
|
|
4083
|
-
}, /* @__PURE__ */ React2.createElement(Select.
|
|
4084
|
-
asChild: true
|
|
4085
|
-
}, /* @__PURE__ */ React2.createElement(NaturalToolbar.Button, {
|
|
4086
|
-
variant: "ghost",
|
|
4087
|
-
classNames: buttonStyles
|
|
4088
|
-
}, /* @__PURE__ */ React2.createElement("span", {
|
|
4089
|
-
className: "sr-only"
|
|
4090
|
-
}, t("heading label")), /* @__PURE__ */ React2.createElement(HeadingIcon, {
|
|
4120
|
+
}, /* @__PURE__ */ React2.createElement(Select.TriggerButton, null, /* @__PURE__ */ React2.createElement(HeadingIcon, {
|
|
4091
4121
|
className: iconStyles
|
|
4092
|
-
}), /* @__PURE__ */ React2.createElement(
|
|
4093
|
-
className: getSize(2),
|
|
4094
|
-
weight: "bold"
|
|
4095
|
-
}))), /* @__PURE__ */ React2.createElement(Select.Portal, null, /* @__PURE__ */ React2.createElement(Select.Content, null, /* @__PURE__ */ React2.createElement(Select.ScrollUpButton, null), /* @__PURE__ */ React2.createElement(Select.Viewport, null, /* @__PURE__ */ React2.createElement(Select.Option, {
|
|
4122
|
+
})), /* @__PURE__ */ React2.createElement(Select.Portal, null, /* @__PURE__ */ React2.createElement(Select.Content, null, /* @__PURE__ */ React2.createElement(Select.ScrollUpButton, null), /* @__PURE__ */ React2.createElement(Select.Viewport, null, /* @__PURE__ */ React2.createElement(Select.Option, {
|
|
4096
4123
|
value: "0"
|
|
4097
|
-
},
|
|
4124
|
+
}, /* @__PURE__ */ React2.createElement(Paragraph, {
|
|
4125
|
+
className: iconStyles
|
|
4126
|
+
})), [
|
|
4098
4127
|
1,
|
|
4099
4128
|
2,
|
|
4100
4129
|
3,
|
|
@@ -4104,28 +4133,45 @@ var MarkdownHeading = () => {
|
|
|
4104
4133
|
].map((level) => /* @__PURE__ */ React2.createElement(Select.Option, {
|
|
4105
4134
|
key: level,
|
|
4106
4135
|
value: String(level)
|
|
4107
|
-
},
|
|
4136
|
+
}, level === 1 && /* @__PURE__ */ React2.createElement(TextHOne, {
|
|
4137
|
+
className: iconStyles
|
|
4138
|
+
}), level === 2 && /* @__PURE__ */ React2.createElement(TextHTwo, {
|
|
4139
|
+
className: iconStyles
|
|
4140
|
+
}), level === 3 && /* @__PURE__ */ React2.createElement(TextHThree, {
|
|
4141
|
+
className: iconStyles
|
|
4142
|
+
}), level === 4 && /* @__PURE__ */ React2.createElement(TextHFour, {
|
|
4143
|
+
className: iconStyles
|
|
4144
|
+
}), level === 5 && /* @__PURE__ */ React2.createElement(TextHFive, {
|
|
4145
|
+
className: iconStyles
|
|
4146
|
+
}), level === 6 && /* @__PURE__ */ React2.createElement(TextHSix, {
|
|
4147
|
+
className: iconStyles
|
|
4148
|
+
})))), /* @__PURE__ */ React2.createElement(Select.ScrollDownButton, null), /* @__PURE__ */ React2.createElement(Select.Arrow, null))));
|
|
4108
4149
|
};
|
|
4109
4150
|
var markdownStyles = [
|
|
4110
4151
|
{
|
|
4111
|
-
|
|
4112
|
-
Icon: TextB
|
|
4152
|
+
type: "strong",
|
|
4153
|
+
Icon: TextB,
|
|
4154
|
+
getState: (state) => state.strong
|
|
4113
4155
|
},
|
|
4114
4156
|
{
|
|
4115
|
-
|
|
4116
|
-
Icon: TextItalic
|
|
4157
|
+
type: "emphasis",
|
|
4158
|
+
Icon: TextItalic,
|
|
4159
|
+
getState: (state) => state.emphasis
|
|
4117
4160
|
},
|
|
4118
4161
|
{
|
|
4119
|
-
|
|
4120
|
-
Icon: TextStrikethrough
|
|
4162
|
+
type: "strikethrough",
|
|
4163
|
+
Icon: TextStrikethrough,
|
|
4164
|
+
getState: (state) => state.strikethrough
|
|
4121
4165
|
},
|
|
4122
4166
|
{
|
|
4123
|
-
|
|
4124
|
-
Icon: Code
|
|
4167
|
+
type: "code",
|
|
4168
|
+
Icon: Code,
|
|
4169
|
+
getState: (state) => state.code
|
|
4125
4170
|
},
|
|
4126
4171
|
{
|
|
4127
|
-
|
|
4128
|
-
Icon: Link
|
|
4172
|
+
type: "link",
|
|
4173
|
+
Icon: Link,
|
|
4174
|
+
getState: (state) => state.link
|
|
4129
4175
|
}
|
|
4130
4176
|
];
|
|
4131
4177
|
var MarkdownStyles = () => {
|
|
@@ -4133,33 +4179,33 @@ var MarkdownStyles = () => {
|
|
|
4133
4179
|
const { t } = useTranslation(translationKey);
|
|
4134
4180
|
return /* @__PURE__ */ React2.createElement(NaturalToolbar.ToggleGroup, {
|
|
4135
4181
|
type: "multiple",
|
|
4136
|
-
value: markdownStyles.filter(({
|
|
4137
|
-
}, markdownStyles.map(({
|
|
4138
|
-
key,
|
|
4139
|
-
value:
|
|
4182
|
+
value: markdownStyles.filter(({ getState }) => state && getState(state)).map(({ type }) => type)
|
|
4183
|
+
}, markdownStyles.map(({ type, getState, Icon }) => /* @__PURE__ */ React2.createElement(ToolbarButton, {
|
|
4184
|
+
key: type,
|
|
4185
|
+
value: type,
|
|
4140
4186
|
Icon,
|
|
4141
4187
|
disabled: state?.blockType === "codeblock",
|
|
4142
|
-
onClick: () => onAction?.({
|
|
4143
|
-
type
|
|
4144
|
-
data:
|
|
4145
|
-
})
|
|
4146
|
-
}, t(`${
|
|
4188
|
+
onClick: state ? () => onAction?.({
|
|
4189
|
+
type,
|
|
4190
|
+
data: !getState(state)
|
|
4191
|
+
}) : void 0
|
|
4192
|
+
}, t(`${type} label`))));
|
|
4147
4193
|
};
|
|
4148
4194
|
var markdownLists = [
|
|
4149
4195
|
{
|
|
4150
|
-
|
|
4196
|
+
type: "list-bullet",
|
|
4151
4197
|
Icon: ListBullets,
|
|
4152
|
-
|
|
4198
|
+
getState: (state) => state.listStyle === "bullet"
|
|
4153
4199
|
},
|
|
4154
4200
|
{
|
|
4155
|
-
|
|
4201
|
+
type: "list-ordered",
|
|
4156
4202
|
Icon: ListNumbers,
|
|
4157
|
-
|
|
4203
|
+
getState: (state) => state.listStyle === "ordered"
|
|
4158
4204
|
},
|
|
4159
4205
|
{
|
|
4160
|
-
|
|
4206
|
+
type: "list-task",
|
|
4161
4207
|
Icon: ListChecks,
|
|
4162
|
-
|
|
4208
|
+
getState: (state) => state.listStyle === "task"
|
|
4163
4209
|
}
|
|
4164
4210
|
];
|
|
4165
4211
|
var MarkdownLists = () => {
|
|
@@ -4168,61 +4214,52 @@ var MarkdownLists = () => {
|
|
|
4168
4214
|
return /* @__PURE__ */ React2.createElement(NaturalToolbar.ToggleGroup, {
|
|
4169
4215
|
type: "single",
|
|
4170
4216
|
value: state?.listStyle ?? void 0
|
|
4171
|
-
}, markdownLists.map(({
|
|
4172
|
-
key,
|
|
4173
|
-
value:
|
|
4217
|
+
}, markdownLists.map(({ type, getState, Icon }) => /* @__PURE__ */ React2.createElement(ToolbarButton, {
|
|
4218
|
+
key: type,
|
|
4219
|
+
value: type,
|
|
4174
4220
|
Icon,
|
|
4175
|
-
onClick: () => onAction?.({
|
|
4176
|
-
type
|
|
4177
|
-
data: state
|
|
4178
|
-
})
|
|
4179
|
-
}, t(`${
|
|
4221
|
+
onClick: state ? () => onAction?.({
|
|
4222
|
+
type,
|
|
4223
|
+
data: !getState(state)
|
|
4224
|
+
}) : void 0
|
|
4225
|
+
}, t(`${type} label`))));
|
|
4180
4226
|
};
|
|
4181
4227
|
var markdownBlocks = [
|
|
4182
4228
|
{
|
|
4183
|
-
|
|
4229
|
+
type: "blockquote",
|
|
4184
4230
|
Icon: Quotes,
|
|
4185
|
-
|
|
4186
|
-
action: (state) => ({
|
|
4187
|
-
type: "blockquote",
|
|
4188
|
-
data: state ? !state.blockQuote : null
|
|
4189
|
-
}),
|
|
4190
|
-
disabled: (state) => false
|
|
4231
|
+
getState: (state) => state.blockQuote
|
|
4191
4232
|
},
|
|
4192
4233
|
{
|
|
4193
|
-
|
|
4234
|
+
type: "codeblock",
|
|
4194
4235
|
Icon: CodeBlock,
|
|
4195
|
-
|
|
4196
|
-
|
|
4197
|
-
|
|
4198
|
-
|
|
4199
|
-
|
|
4200
|
-
|
|
4236
|
+
getState: (state) => state.blockQuote,
|
|
4237
|
+
disabled: (state) => !state.blankLine
|
|
4238
|
+
},
|
|
4239
|
+
{
|
|
4240
|
+
type: "table",
|
|
4241
|
+
Icon: Table2,
|
|
4242
|
+
getState: (state) => state.blockType === "tablecell",
|
|
4243
|
+
disabled: (state) => !state.blankLine
|
|
4201
4244
|
}
|
|
4202
4245
|
];
|
|
4203
4246
|
var MarkdownBlocks = () => {
|
|
4204
4247
|
const { onAction, state } = useToolbarContext("MarkdownStyles");
|
|
4205
4248
|
const { t } = useTranslation(translationKey);
|
|
4206
|
-
|
|
4207
|
-
|
|
4208
|
-
|
|
4209
|
-
|
|
4210
|
-
|
|
4211
|
-
|
|
4249
|
+
const value = markdownBlocks.find(({ getState }) => state && getState(state));
|
|
4250
|
+
return /* @__PURE__ */ React2.createElement(NaturalToolbar.ToggleGroup, {
|
|
4251
|
+
type: "single",
|
|
4252
|
+
value: value?.type
|
|
4253
|
+
}, markdownBlocks.map(({ type, disabled, getState, Icon }) => /* @__PURE__ */ React2.createElement(ToolbarButton, {
|
|
4254
|
+
key: type,
|
|
4255
|
+
value: type,
|
|
4212
4256
|
Icon,
|
|
4213
|
-
|
|
4214
|
-
|
|
4215
|
-
|
|
4216
|
-
|
|
4217
|
-
|
|
4218
|
-
|
|
4219
|
-
}),
|
|
4220
|
-
classNames: buttonStyles
|
|
4221
|
-
}, /* @__PURE__ */ React2.createElement(Table2, {
|
|
4222
|
-
className: iconStyles
|
|
4223
|
-
}), /* @__PURE__ */ React2.createElement("span", {
|
|
4224
|
-
className: "sr-only"
|
|
4225
|
-
}, t("table label"))));
|
|
4257
|
+
disabled: !state || disabled?.(state),
|
|
4258
|
+
onClick: state ? () => onAction?.({
|
|
4259
|
+
type,
|
|
4260
|
+
data: !getState(state)
|
|
4261
|
+
}) : void 0
|
|
4262
|
+
}, t(`${type} label`))));
|
|
4226
4263
|
};
|
|
4227
4264
|
var MarkdownStandard = () => /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement(MarkdownHeading, null), /* @__PURE__ */ React2.createElement(MarkdownStyles, null), /* @__PURE__ */ React2.createElement(MarkdownLists, null), /* @__PURE__ */ React2.createElement(MarkdownBlocks, null));
|
|
4228
4265
|
var MarkdownExtended = () => {
|
|
@@ -4230,6 +4267,7 @@ var MarkdownExtended = () => {
|
|
|
4230
4267
|
const { t } = useTranslation(translationKey);
|
|
4231
4268
|
return /* @__PURE__ */ React2.createElement(NaturalToolbar.Button, {
|
|
4232
4269
|
variant: "ghost",
|
|
4270
|
+
"data-testid": "editor.toolbar.comment",
|
|
4233
4271
|
onClick: () => onAction?.({
|
|
4234
4272
|
type: "comment"
|
|
4235
4273
|
}),
|
|
@@ -4379,7 +4417,7 @@ var useActionHandler = (view) => {
|
|
|
4379
4417
|
break;
|
|
4380
4418
|
case "list-ordered":
|
|
4381
4419
|
case "list-bullet":
|
|
4382
|
-
case "list-
|
|
4420
|
+
case "list-task":
|
|
4383
4421
|
listType = action.type === "list-ordered" ? List.Ordered : action.type === "list-bullet" ? List.Bullet : List.Task;
|
|
4384
4422
|
(action.data === false ? removeList(listType) : action.data === true ? addList(listType) : toggleList(listType))(view);
|
|
4385
4423
|
break;
|
|
@@ -4643,6 +4681,7 @@ export {
|
|
|
4643
4681
|
defaultSlots,
|
|
4644
4682
|
defaultTextSlots,
|
|
4645
4683
|
defaultTheme,
|
|
4684
|
+
editorMode,
|
|
4646
4685
|
editorWithToolbarLayout,
|
|
4647
4686
|
focusComment,
|
|
4648
4687
|
formatting,
|
|
@@ -4652,7 +4691,7 @@ export {
|
|
|
4652
4691
|
hr,
|
|
4653
4692
|
image,
|
|
4654
4693
|
insertTable,
|
|
4655
|
-
|
|
4694
|
+
keymap8 as keymap,
|
|
4656
4695
|
link,
|
|
4657
4696
|
listener,
|
|
4658
4697
|
logChanges,
|