@dxos/react-ui-editor 0.4.4-main.8a6f0d0 → 0.4.4-main.9f75c97
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 +53 -29
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/types/src/components/Toolbar/Toolbar.d.ts.map +1 -1
- package/dist/types/src/components/Toolbar/Toolbar.stories.d.ts.map +1 -1
- package/dist/types/src/extensions/markdown/code.d.ts.map +1 -1
- package/dist/types/src/extensions/markdown/formatting.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/styles/layout.d.ts +4 -1
- package/dist/types/src/styles/layout.d.ts.map +1 -1
- package/package.json +24 -24
- package/src/components/TextEditor/hooks.stories.tsx +4 -4
- package/src/components/Toolbar/Toolbar.stories.tsx +5 -2
- package/src/components/Toolbar/Toolbar.tsx +10 -13
- package/src/extensions/markdown/code.ts +37 -25
- package/src/extensions/markdown/formatting.test.ts +1 -1
- package/src/extensions/markdown/formatting.ts +1 -0
- package/src/index.ts +7 -1
- package/src/styles/layout.ts +6 -1
|
@@ -1091,7 +1091,10 @@ var tokens = tailwindConfig({}).theme;
|
|
|
1091
1091
|
var getToken = (path, defaultValue = void 0) => get2(tokens, path, defaultValue);
|
|
1092
1092
|
|
|
1093
1093
|
// packages/ui/react-ui-editor/src/styles/layout.ts
|
|
1094
|
-
var editorWithToolbarLayout = "
|
|
1094
|
+
var editorWithToolbarLayout = "grid grid-cols-1 grid-rows-[min-content_1fr] justify-center content-start overflow-hidden";
|
|
1095
|
+
var editorFillLayoutRoot = "min-bs-full grid";
|
|
1096
|
+
var editorFillLayoutEditor = "min-bs-full";
|
|
1097
|
+
var editorHalfViewportOverscrollContent = "after:block after:min-bs-[50dvh] after:pointer-events-none";
|
|
1095
1098
|
|
|
1096
1099
|
// packages/ui/react-ui-editor/src/util.ts
|
|
1097
1100
|
import { log } from "@dxos/log";
|
|
@@ -1791,41 +1794,50 @@ var styles4 = EditorView9.baseTheme({
|
|
|
1791
1794
|
"& .cm-code": {
|
|
1792
1795
|
fontFamily: getToken("fontFamily.mono", []).join(",")
|
|
1793
1796
|
},
|
|
1794
|
-
"& .cm-codeblock": {
|
|
1797
|
+
"& .cm-codeblock-line": {
|
|
1798
|
+
paddingInline: "1rem !important"
|
|
1799
|
+
},
|
|
1800
|
+
"& .cm-codeblock-end": {
|
|
1801
|
+
display: "inline-block",
|
|
1795
1802
|
width: "100%",
|
|
1796
|
-
paddingInline: "1rem !important",
|
|
1797
1803
|
position: "relative",
|
|
1798
1804
|
"&::after": {
|
|
1799
|
-
content: '""',
|
|
1800
1805
|
position: "absolute",
|
|
1801
|
-
inset: 0
|
|
1802
|
-
|
|
1803
|
-
},
|
|
1804
|
-
"&light .cm-codeblock": {
|
|
1805
|
-
"&::after": {
|
|
1806
|
-
background: getToken("extend.semanticColors.input.light"),
|
|
1807
|
-
mixBlendMode: "darken"
|
|
1808
|
-
}
|
|
1809
|
-
},
|
|
1810
|
-
"&dark .cm-codeblock": {
|
|
1811
|
-
"&::after": {
|
|
1812
|
-
background: getToken("extend.semanticColors.input.dark"),
|
|
1813
|
-
mixBlendMode: "lighten"
|
|
1806
|
+
inset: 0,
|
|
1807
|
+
content: '""'
|
|
1814
1808
|
}
|
|
1815
1809
|
},
|
|
1816
1810
|
"& .cm-codeblock-first": {
|
|
1817
|
-
display: "inline-block",
|
|
1818
1811
|
"&::after": {
|
|
1819
1812
|
borderTopLeftRadius: ".5rem",
|
|
1820
1813
|
borderTopRightRadius: ".5rem"
|
|
1821
1814
|
}
|
|
1822
1815
|
},
|
|
1823
1816
|
"& .cm-codeblock-last": {
|
|
1824
|
-
display: "inline-block",
|
|
1825
1817
|
"&::after": {
|
|
1826
1818
|
borderBottomLeftRadius: ".5rem",
|
|
1827
1819
|
borderBottomRightRadius: ".5rem"
|
|
1828
1820
|
}
|
|
1821
|
+
},
|
|
1822
|
+
"&light .cm-codeblock-line, &light .cm-activeLine.cm-codeblock-line": {
|
|
1823
|
+
background: getToken("extend.semanticColors.input.light"),
|
|
1824
|
+
mixBlendMode: "darken"
|
|
1825
|
+
},
|
|
1826
|
+
"&dark .cm-codeblock-line, &dark .cm-activeLine.cm-codeblock-line": {
|
|
1827
|
+
background: getToken("extend.semanticColors.input.dark"),
|
|
1828
|
+
mixBlendMode: "lighten"
|
|
1829
|
+
},
|
|
1830
|
+
"&light .cm-codeblock-first, &light .cm-codeblock-last": {
|
|
1831
|
+
mixBlendMode: "darken",
|
|
1832
|
+
"&::after": {
|
|
1833
|
+
background: getToken("extend.semanticColors.input.light")
|
|
1834
|
+
}
|
|
1835
|
+
},
|
|
1836
|
+
"&dark .cm-codeblock-first, &dark .cm-codeblock-last": {
|
|
1837
|
+
mixBlendMode: "lighten",
|
|
1838
|
+
"&::after": {
|
|
1839
|
+
background: getToken("extend.semanticColors.input.dark")
|
|
1840
|
+
}
|
|
1829
1841
|
}
|
|
1830
1842
|
});
|
|
1831
1843
|
var getLineRange = (lines, from, to) => {
|
|
@@ -1848,8 +1860,8 @@ var LineWidget = class extends WidgetType2 {
|
|
|
1848
1860
|
return el;
|
|
1849
1861
|
}
|
|
1850
1862
|
};
|
|
1851
|
-
var top = new LineWidget("cm-codeblock-first");
|
|
1852
|
-
var bottom = new LineWidget("cm-codeblock-last");
|
|
1863
|
+
var top = new LineWidget("cm-codeblock-end cm-codeblock-first");
|
|
1864
|
+
var bottom = new LineWidget("cm-codeblock-end cm-codeblock-last");
|
|
1853
1865
|
var buildDecorations = (view) => {
|
|
1854
1866
|
const builder = new RangeSetBuilder();
|
|
1855
1867
|
const { state } = view;
|
|
@@ -1859,17 +1871,17 @@ var buildDecorations = (view) => {
|
|
|
1859
1871
|
syntaxTree(state).iterate({
|
|
1860
1872
|
enter: (node) => {
|
|
1861
1873
|
if (node.name === "FencedCode") {
|
|
1862
|
-
const
|
|
1874
|
+
const editing = !view.state.readOnly && cursor >= node.from && cursor <= node.to;
|
|
1863
1875
|
const range = getLineRange(blocks, node.from, node.to);
|
|
1864
1876
|
for (let i = range[0]; i <= range[1]; i++) {
|
|
1865
1877
|
const block = blocks[i];
|
|
1866
|
-
if (!
|
|
1878
|
+
if (!editing && (i === range[0] || i === range[1])) {
|
|
1867
1879
|
builder.add(block.from, block.to, Decoration4.replace({
|
|
1868
1880
|
widget: i === range[0] ? top : bottom
|
|
1869
1881
|
}));
|
|
1870
1882
|
} else {
|
|
1871
1883
|
builder.add(block.from, block.from, Decoration4.line({
|
|
1872
|
-
class: mx2("cm-code cm-codeblock", i === range[0] && "cm-codeblock-first", i === range[1] && "cm-codeblock-last")
|
|
1884
|
+
class: mx2("cm-code cm-codeblock-line", i === range[0] && "cm-codeblock-first", i === range[1] && "cm-codeblock-last")
|
|
1873
1885
|
}));
|
|
1874
1886
|
}
|
|
1875
1887
|
}
|
|
@@ -2177,6 +2189,7 @@ var snippets = {
|
|
|
2177
2189
|
codeblock: snippet([
|
|
2178
2190
|
//
|
|
2179
2191
|
"```#{}",
|
|
2192
|
+
"",
|
|
2180
2193
|
"```"
|
|
2181
2194
|
].join("\n")),
|
|
2182
2195
|
table: snippet([
|
|
@@ -4105,6 +4118,7 @@ var ToolbarSeparator = () => /* @__PURE__ */ React2.createElement("div", {
|
|
|
4105
4118
|
className: "grow"
|
|
4106
4119
|
});
|
|
4107
4120
|
var MarkdownHeading = () => {
|
|
4121
|
+
const { t } = useTranslation(translationKey);
|
|
4108
4122
|
const { onAction, state } = useToolbarContext("MarkdownFormatting");
|
|
4109
4123
|
const blockType = state ? state.blockType : "paragraph";
|
|
4110
4124
|
const header = blockType && /heading(\d)/.exec(blockType);
|
|
@@ -4117,9 +4131,16 @@ var MarkdownHeading = () => {
|
|
|
4117
4131
|
type: "heading",
|
|
4118
4132
|
data: parseInt(value2)
|
|
4119
4133
|
})
|
|
4120
|
-
}, /* @__PURE__ */ React2.createElement(
|
|
4134
|
+
}, /* @__PURE__ */ React2.createElement(NaturalToolbar.Button, {
|
|
4135
|
+
asChild: true
|
|
4136
|
+
}, /* @__PURE__ */ React2.createElement(Select.TriggerButton, {
|
|
4137
|
+
variant: "ghost",
|
|
4138
|
+
classNames: buttonStyles
|
|
4139
|
+
}, /* @__PURE__ */ React2.createElement("span", {
|
|
4140
|
+
className: "sr-only"
|
|
4141
|
+
}, t("heading label")), /* @__PURE__ */ React2.createElement(HeadingIcon, {
|
|
4121
4142
|
className: iconStyles
|
|
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, {
|
|
4143
|
+
}))), /* @__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, {
|
|
4123
4144
|
value: "0"
|
|
4124
4145
|
}, /* @__PURE__ */ React2.createElement(Paragraph, {
|
|
4125
4146
|
className: iconStyles
|
|
@@ -4213,7 +4234,7 @@ var MarkdownLists = () => {
|
|
|
4213
4234
|
const { t } = useTranslation(translationKey);
|
|
4214
4235
|
return /* @__PURE__ */ React2.createElement(NaturalToolbar.ToggleGroup, {
|
|
4215
4236
|
type: "single",
|
|
4216
|
-
value: state?.listStyle
|
|
4237
|
+
value: state?.listStyle ? `list-${state.listStyle}` : ""
|
|
4217
4238
|
}, markdownLists.map(({ type, getState, Icon }) => /* @__PURE__ */ React2.createElement(ToolbarButton, {
|
|
4218
4239
|
key: type,
|
|
4219
4240
|
value: type,
|
|
@@ -4233,7 +4254,7 @@ var markdownBlocks = [
|
|
|
4233
4254
|
{
|
|
4234
4255
|
type: "codeblock",
|
|
4235
4256
|
Icon: CodeBlock,
|
|
4236
|
-
getState: (state) => state.
|
|
4257
|
+
getState: (state) => state.blockType === "codeblock",
|
|
4237
4258
|
disabled: (state) => !state.blankLine
|
|
4238
4259
|
},
|
|
4239
4260
|
{
|
|
@@ -4249,7 +4270,7 @@ var MarkdownBlocks = () => {
|
|
|
4249
4270
|
const value = markdownBlocks.find(({ getState }) => state && getState(state));
|
|
4250
4271
|
return /* @__PURE__ */ React2.createElement(NaturalToolbar.ToggleGroup, {
|
|
4251
4272
|
type: "single",
|
|
4252
|
-
value: value?.type
|
|
4273
|
+
value: value?.type ?? ""
|
|
4253
4274
|
}, markdownBlocks.map(({ type, disabled, getState, Icon }) => /* @__PURE__ */ React2.createElement(ToolbarButton, {
|
|
4254
4275
|
key: type,
|
|
4255
4276
|
value: type,
|
|
@@ -4681,6 +4702,9 @@ export {
|
|
|
4681
4702
|
defaultSlots,
|
|
4682
4703
|
defaultTextSlots,
|
|
4683
4704
|
defaultTheme,
|
|
4705
|
+
editorFillLayoutEditor,
|
|
4706
|
+
editorFillLayoutRoot,
|
|
4707
|
+
editorHalfViewportOverscrollContent,
|
|
4684
4708
|
editorMode,
|
|
4685
4709
|
editorWithToolbarLayout,
|
|
4686
4710
|
focusComment,
|