@dxos/react-ui-editor 0.3.11-main.800163e → 0.3.11-main.80db41b
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 +55 -26
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/types/src/components/TextEditor/TextEditor.d.ts.map +1 -1
- package/dist/types/src/components/TextEditor/automerge.stories.d.ts.map +1 -1
- package/dist/types/src/components/Toolbar/Toolbar.d.ts +6 -5
- package/dist/types/src/components/Toolbar/Toolbar.d.ts.map +1 -1
- package/dist/types/src/components/Toolbar/Toolbar.stories.d.ts +2 -3
- package/dist/types/src/components/Toolbar/Toolbar.stories.d.ts.map +1 -1
- package/dist/types/src/extensions/comments.d.ts.map +1 -1
- package/dist/types/src/extensions/markdown/code.d.ts.map +1 -1
- package/dist/types/src/hooks/useTextModel.d.ts +12 -0
- package/dist/types/src/hooks/useTextModel.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +1 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/themes/default.d.ts.map +1 -1
- package/package.json +24 -24
- package/src/components/TextEditor/TextEditor.tsx +3 -4
- package/src/components/TextEditor/automerge.stories.tsx +1 -2
- package/src/components/Toolbar/Toolbar.tsx +19 -16
- package/src/extensions/awareness.ts +4 -1
- package/src/extensions/blast.ts +4 -1
- package/src/extensions/comments.ts +12 -2
- package/src/extensions/markdown/code.ts +12 -4
- package/src/extensions/markdown/link.ts +8 -2
- package/src/hooks/useTextModel.ts +17 -1
- package/src/index.ts +1 -1
- package/src/themes/default.ts +7 -4
- package/dist/types/src/components/TextEditor/comments.stories.d.ts +0 -26
- package/dist/types/src/components/TextEditor/comments.stories.d.ts.map +0 -1
- package/src/components/TextEditor/comments.stories.tsx +0 -357
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// packages/ui/react-ui-editor/src/index.ts
|
|
2
2
|
import { TextKind } from "@dxos/protocols/proto/dxos/echo/model/text";
|
|
3
3
|
import { Doc, YText, YXmlFragment } from "@dxos/text-model";
|
|
4
|
+
import { keymap as keymap7 } from "@codemirror/view";
|
|
4
5
|
|
|
5
6
|
// packages/ui/react-ui-editor/src/components/TextEditor/index.ts
|
|
6
7
|
import { tags as tags2 } from "@lezer/highlight";
|
|
@@ -13,7 +14,7 @@ import defaultsDeep2 from "lodash.defaultsdeep";
|
|
|
13
14
|
import React, { forwardRef, useCallback, useEffect as useEffect2, useImperativeHandle, useRef, useState } from "react";
|
|
14
15
|
import { log as log2 } from "@dxos/log";
|
|
15
16
|
import { useThemeContext } from "@dxos/react-ui";
|
|
16
|
-
import {
|
|
17
|
+
import { focusRing, mx as mx3 } from "@dxos/react-ui-theme";
|
|
17
18
|
import { isNotFalsy as isNotFalsy3 } from "@dxos/util";
|
|
18
19
|
|
|
19
20
|
// packages/ui/react-ui-editor/src/extensions/autocomplete.ts
|
|
@@ -782,7 +783,7 @@ var Blaster = class {
|
|
|
782
783
|
initialize() {
|
|
783
784
|
invariant(!this._canvas && !this._ctx, void 0, {
|
|
784
785
|
F: __dxlog_file,
|
|
785
|
-
L:
|
|
786
|
+
L: 141,
|
|
786
787
|
S: this,
|
|
787
788
|
A: [
|
|
788
789
|
"!this._canvas && !this._ctx",
|
|
@@ -819,7 +820,7 @@ var Blaster = class {
|
|
|
819
820
|
start() {
|
|
820
821
|
invariant(this._canvas && this._ctx, void 0, {
|
|
821
822
|
F: __dxlog_file,
|
|
822
|
-
L:
|
|
823
|
+
L: 180,
|
|
823
824
|
S: this,
|
|
824
825
|
A: [
|
|
825
826
|
"this._canvas && this._ctx",
|
|
@@ -1073,11 +1074,25 @@ var logChanges = (trs) => {
|
|
|
1073
1074
|
|
|
1074
1075
|
// packages/ui/react-ui-editor/src/extensions/comments.ts
|
|
1075
1076
|
var styles2 = EditorView5.baseTheme({
|
|
1076
|
-
"& .cm-comment": {
|
|
1077
|
+
"&light .cm-comment, &light .cm-comment-current": {
|
|
1078
|
+
mixBlendMode: "darken"
|
|
1079
|
+
},
|
|
1080
|
+
"&dark .cm-comment, &dark .cm-comment-current": {
|
|
1081
|
+
mixBlendMode: "plus-lighter"
|
|
1082
|
+
},
|
|
1083
|
+
"&light .cm-comment": {
|
|
1077
1084
|
backgroundColor: getToken("extend.colors.yellow.50")
|
|
1078
1085
|
},
|
|
1079
|
-
"& .cm-comment-current": {
|
|
1086
|
+
"&light .cm-comment-current": {
|
|
1080
1087
|
backgroundColor: getToken("extend.colors.yellow.100")
|
|
1088
|
+
},
|
|
1089
|
+
"&dark .cm-comment": {
|
|
1090
|
+
color: getToken("extend.colors.yellow.50"),
|
|
1091
|
+
backgroundColor: getToken("extend.colors.yellow.900")
|
|
1092
|
+
},
|
|
1093
|
+
"&dark .cm-comment-current": {
|
|
1094
|
+
color: getToken("extend.colors.yellow.100"),
|
|
1095
|
+
backgroundColor: getToken("extend.colors.yellow.950")
|
|
1081
1096
|
}
|
|
1082
1097
|
});
|
|
1083
1098
|
var commentMark = Decoration2.mark({
|
|
@@ -1703,12 +1718,11 @@ import { ViewPlugin as ViewPlugin3, EditorView as EditorView8, Decoration as Dec
|
|
|
1703
1718
|
import { mx as mx2 } from "@dxos/react-ui-theme";
|
|
1704
1719
|
var styles3 = EditorView8.baseTheme({
|
|
1705
1720
|
"& .cm-code": {
|
|
1706
|
-
paddingInline: "1rem !important",
|
|
1707
1721
|
fontFamily: getToken("fontFamily.mono", []).join(",")
|
|
1708
1722
|
},
|
|
1709
1723
|
"& .cm-codeblock": {
|
|
1710
|
-
display: "inline-block",
|
|
1711
1724
|
width: "100%",
|
|
1725
|
+
paddingInline: "1rem !important",
|
|
1712
1726
|
position: "relative",
|
|
1713
1727
|
"&::after": {
|
|
1714
1728
|
content: '""',
|
|
@@ -1729,12 +1743,14 @@ var styles3 = EditorView8.baseTheme({
|
|
|
1729
1743
|
}
|
|
1730
1744
|
},
|
|
1731
1745
|
"& .cm-codeblock-first": {
|
|
1746
|
+
display: "inline-block",
|
|
1732
1747
|
"&::after": {
|
|
1733
1748
|
borderTopLeftRadius: ".5rem",
|
|
1734
1749
|
borderTopRightRadius: ".5rem"
|
|
1735
1750
|
}
|
|
1736
1751
|
},
|
|
1737
1752
|
"& .cm-codeblock-last": {
|
|
1753
|
+
display: "inline-block",
|
|
1738
1754
|
"&::after": {
|
|
1739
1755
|
borderBottomLeftRadius: ".5rem",
|
|
1740
1756
|
borderBottomRightRadius: ".5rem"
|
|
@@ -1782,7 +1798,7 @@ var buildDecorations = (view) => {
|
|
|
1782
1798
|
}));
|
|
1783
1799
|
} else {
|
|
1784
1800
|
builder.add(block.from, block.from, Decoration3.line({
|
|
1785
|
-
class: mx2("cm-code cm-codeblock")
|
|
1801
|
+
class: mx2("cm-code cm-codeblock", i === range[0] && "cm-codeblock-first", i === range[1] && "cm-codeblock-last")
|
|
1786
1802
|
}));
|
|
1787
1803
|
}
|
|
1788
1804
|
}
|
|
@@ -2589,11 +2605,11 @@ var defaultTheme = {
|
|
|
2589
2605
|
fontSize: "16px"
|
|
2590
2606
|
},
|
|
2591
2607
|
"&light .cm-content": {
|
|
2592
|
-
color: get3(tokens, "extend.
|
|
2608
|
+
color: get3(tokens, "extend.semanticColors.base.fg.light", "black"),
|
|
2593
2609
|
caretColor: "black"
|
|
2594
2610
|
},
|
|
2595
2611
|
"&dark .cm-content": {
|
|
2596
|
-
color: get3(tokens, "extend.
|
|
2612
|
+
color: get3(tokens, "extend.semanticColors.base.fg.dark", "white"),
|
|
2597
2613
|
caretColor: "white"
|
|
2598
2614
|
},
|
|
2599
2615
|
//
|
|
@@ -2605,8 +2621,11 @@ var defaultTheme = {
|
|
|
2605
2621
|
"&dark .cm-cursor, &dark .cm-dropCursor": {
|
|
2606
2622
|
borderLeft: "2px solid white"
|
|
2607
2623
|
},
|
|
2608
|
-
".cm-placeholder": {
|
|
2609
|
-
|
|
2624
|
+
"&light .cm-placeholder": {
|
|
2625
|
+
color: get3(tokens, "extend.semanticColors.description.light", "rgba(0,0,0,.2)")
|
|
2626
|
+
},
|
|
2627
|
+
"&dark .cm-placeholder": {
|
|
2628
|
+
color: get3(tokens, "extend.semanticColors.description.dark", "rgba(255,255,255,.2)")
|
|
2610
2629
|
},
|
|
2611
2630
|
//
|
|
2612
2631
|
// line
|
|
@@ -2947,11 +2966,10 @@ var MarkdownEditor = /* @__PURE__ */ forwardRef(({ readonly, placeholder: placeh
|
|
|
2947
2966
|
});
|
|
2948
2967
|
var defaultSlots = {
|
|
2949
2968
|
root: {
|
|
2950
|
-
|
|
2951
|
-
className: mx3("flex flex-col grow overflow-y-auto", attentionSurface)
|
|
2969
|
+
className: mx3("grow", focusRing)
|
|
2952
2970
|
},
|
|
2953
2971
|
editor: {
|
|
2954
|
-
className: "
|
|
2972
|
+
className: "bs-full"
|
|
2955
2973
|
}
|
|
2956
2974
|
};
|
|
2957
2975
|
var defaultTextSlots = {
|
|
@@ -2968,6 +2986,16 @@ import React2 from "react";
|
|
|
2968
2986
|
import { Button, DensityProvider, Select } from "@dxos/react-ui";
|
|
2969
2987
|
import { getSize } from "@dxos/react-ui-theme";
|
|
2970
2988
|
var [ToolbarContextProvider, useToolbarContext] = createContext("Toolbar");
|
|
2989
|
+
var ToolbarRoot = ({ children, onAction }) => {
|
|
2990
|
+
return /* @__PURE__ */ React2.createElement(ToolbarContextProvider, {
|
|
2991
|
+
onAction
|
|
2992
|
+
}, /* @__PURE__ */ React2.createElement(DensityProvider, {
|
|
2993
|
+
density: "fine"
|
|
2994
|
+
}, /* @__PURE__ */ React2.createElement("div", {
|
|
2995
|
+
role: "toolbar",
|
|
2996
|
+
className: "flex w-full shrink-0 p-2 gap-4 items-center whitespace-nowrap overflow-hidden"
|
|
2997
|
+
}, children)));
|
|
2998
|
+
};
|
|
2971
2999
|
var ToolbarButton = ({ Icon, onClick, title }) => {
|
|
2972
3000
|
const { onAction } = useToolbarContext("ToolbarButton");
|
|
2973
3001
|
const handleClick = () => {
|
|
@@ -2985,16 +3013,6 @@ var ToolbarButton = ({ Icon, onClick, title }) => {
|
|
|
2985
3013
|
className: getSize(5)
|
|
2986
3014
|
}));
|
|
2987
3015
|
};
|
|
2988
|
-
var ToolbarRoot = ({ children, onAction }) => {
|
|
2989
|
-
return /* @__PURE__ */ React2.createElement(ToolbarContextProvider, {
|
|
2990
|
-
onAction
|
|
2991
|
-
}, /* @__PURE__ */ React2.createElement(DensityProvider, {
|
|
2992
|
-
density: "fine"
|
|
2993
|
-
}, /* @__PURE__ */ React2.createElement("div", {
|
|
2994
|
-
role: "toolbar",
|
|
2995
|
-
className: "flex w-full shrink-0 p-2 gap-4 items-center whitespace-nowrap overflow-hidden"
|
|
2996
|
-
}, children)));
|
|
2997
|
-
};
|
|
2998
3016
|
var ToolbarSeparator = () => /* @__PURE__ */ React2.createElement("div", {
|
|
2999
3017
|
className: "grow"
|
|
3000
3018
|
});
|
|
@@ -3411,10 +3429,19 @@ var useTextModel = (props) => {
|
|
|
3411
3429
|
]);
|
|
3412
3430
|
return model;
|
|
3413
3431
|
};
|
|
3432
|
+
var useInMemoryTextModel = ({ id, defaultContent }) => {
|
|
3433
|
+
const [content, setContent] = useState4(defaultContent ?? "");
|
|
3434
|
+
return {
|
|
3435
|
+
id,
|
|
3436
|
+
content,
|
|
3437
|
+
setContent,
|
|
3438
|
+
text: () => content
|
|
3439
|
+
};
|
|
3440
|
+
};
|
|
3414
3441
|
var createModel = ({ space, identity, text }) => {
|
|
3415
3442
|
invariant3(isAutomergeObject(text), void 0, {
|
|
3416
3443
|
F: __dxlog_file6,
|
|
3417
|
-
L:
|
|
3444
|
+
L: 50,
|
|
3418
3445
|
S: void 0,
|
|
3419
3446
|
A: [
|
|
3420
3447
|
"isAutomergeObject(text)",
|
|
@@ -3498,6 +3525,7 @@ export {
|
|
|
3498
3525
|
image,
|
|
3499
3526
|
insertCodeblock,
|
|
3500
3527
|
insertTable,
|
|
3528
|
+
keymap7 as keymap,
|
|
3501
3529
|
link,
|
|
3502
3530
|
listener,
|
|
3503
3531
|
logChanges,
|
|
@@ -3524,6 +3552,7 @@ export {
|
|
|
3524
3552
|
useActionHandler,
|
|
3525
3553
|
useComments,
|
|
3526
3554
|
useEditorView,
|
|
3555
|
+
useInMemoryTextModel,
|
|
3527
3556
|
useTextEditor,
|
|
3528
3557
|
useTextModel,
|
|
3529
3558
|
useToolbarContext
|