@dxos/react-ui-editor 0.4.4-main.8a6f0d0 → 0.4.4-main.b30fc36

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.
@@ -1791,41 +1791,50 @@ var styles4 = EditorView9.baseTheme({
1791
1791
  "& .cm-code": {
1792
1792
  fontFamily: getToken("fontFamily.mono", []).join(",")
1793
1793
  },
1794
- "& .cm-codeblock": {
1794
+ "& .cm-codeblock-line": {
1795
+ paddingInline: "1rem !important"
1796
+ },
1797
+ "& .cm-codeblock-end": {
1798
+ display: "inline-block",
1795
1799
  width: "100%",
1796
- paddingInline: "1rem !important",
1797
1800
  position: "relative",
1798
1801
  "&::after": {
1799
- content: '""',
1800
1802
  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"
1803
+ inset: 0,
1804
+ content: '""'
1814
1805
  }
1815
1806
  },
1816
1807
  "& .cm-codeblock-first": {
1817
- display: "inline-block",
1818
1808
  "&::after": {
1819
1809
  borderTopLeftRadius: ".5rem",
1820
1810
  borderTopRightRadius: ".5rem"
1821
1811
  }
1822
1812
  },
1823
1813
  "& .cm-codeblock-last": {
1824
- display: "inline-block",
1825
1814
  "&::after": {
1826
1815
  borderBottomLeftRadius: ".5rem",
1827
1816
  borderBottomRightRadius: ".5rem"
1828
1817
  }
1818
+ },
1819
+ "&light .cm-codeblock-line, &light .cm-activeLine.cm-codeblock-line": {
1820
+ background: getToken("extend.semanticColors.input.light"),
1821
+ mixBlendMode: "darken"
1822
+ },
1823
+ "&dark .cm-codeblock-line, &dark .cm-activeLine.cm-codeblock-line": {
1824
+ background: getToken("extend.semanticColors.input.dark"),
1825
+ mixBlendMode: "lighten"
1826
+ },
1827
+ "&light .cm-codeblock-first, &light .cm-codeblock-last": {
1828
+ mixBlendMode: "darken",
1829
+ "&::after": {
1830
+ background: getToken("extend.semanticColors.input.light")
1831
+ }
1832
+ },
1833
+ "&dark .cm-codeblock-first, &dark .cm-codeblock-last": {
1834
+ mixBlendMode: "lighten",
1835
+ "&::after": {
1836
+ background: getToken("extend.semanticColors.input.dark")
1837
+ }
1829
1838
  }
1830
1839
  });
1831
1840
  var getLineRange = (lines, from, to) => {
@@ -1848,8 +1857,8 @@ var LineWidget = class extends WidgetType2 {
1848
1857
  return el;
1849
1858
  }
1850
1859
  };
1851
- var top = new LineWidget("cm-codeblock-first");
1852
- var bottom = new LineWidget("cm-codeblock-last");
1860
+ var top = new LineWidget("cm-codeblock-end cm-codeblock-first");
1861
+ var bottom = new LineWidget("cm-codeblock-end cm-codeblock-last");
1853
1862
  var buildDecorations = (view) => {
1854
1863
  const builder = new RangeSetBuilder();
1855
1864
  const { state } = view;
@@ -1859,17 +1868,17 @@ var buildDecorations = (view) => {
1859
1868
  syntaxTree(state).iterate({
1860
1869
  enter: (node) => {
1861
1870
  if (node.name === "FencedCode") {
1862
- const edit = !view.state.readOnly && cursor >= node.from && cursor <= node.to;
1871
+ const editing = !view.state.readOnly && cursor >= node.from && cursor <= node.to;
1863
1872
  const range = getLineRange(blocks, node.from, node.to);
1864
1873
  for (let i = range[0]; i <= range[1]; i++) {
1865
1874
  const block = blocks[i];
1866
- if (!edit && (i === range[0] || i === range[1])) {
1875
+ if (!editing && (i === range[0] || i === range[1])) {
1867
1876
  builder.add(block.from, block.to, Decoration4.replace({
1868
1877
  widget: i === range[0] ? top : bottom
1869
1878
  }));
1870
1879
  } else {
1871
1880
  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")
1881
+ class: mx2("cm-code cm-codeblock-line", i === range[0] && "cm-codeblock-first", i === range[1] && "cm-codeblock-last")
1873
1882
  }));
1874
1883
  }
1875
1884
  }
@@ -2177,6 +2186,7 @@ var snippets = {
2177
2186
  codeblock: snippet([
2178
2187
  //
2179
2188
  "```#{}",
2189
+ "",
2180
2190
  "```"
2181
2191
  ].join("\n")),
2182
2192
  table: snippet([
@@ -4105,6 +4115,7 @@ var ToolbarSeparator = () => /* @__PURE__ */ React2.createElement("div", {
4105
4115
  className: "grow"
4106
4116
  });
4107
4117
  var MarkdownHeading = () => {
4118
+ const { t } = useTranslation(translationKey);
4108
4119
  const { onAction, state } = useToolbarContext("MarkdownFormatting");
4109
4120
  const blockType = state ? state.blockType : "paragraph";
4110
4121
  const header = blockType && /heading(\d)/.exec(blockType);
@@ -4117,9 +4128,16 @@ var MarkdownHeading = () => {
4117
4128
  type: "heading",
4118
4129
  data: parseInt(value2)
4119
4130
  })
4120
- }, /* @__PURE__ */ React2.createElement(Select.TriggerButton, null, /* @__PURE__ */ React2.createElement(HeadingIcon, {
4131
+ }, /* @__PURE__ */ React2.createElement(NaturalToolbar.Button, {
4132
+ asChild: true
4133
+ }, /* @__PURE__ */ React2.createElement(Select.TriggerButton, {
4134
+ variant: "ghost",
4135
+ classNames: buttonStyles
4136
+ }, /* @__PURE__ */ React2.createElement("span", {
4137
+ className: "sr-only"
4138
+ }, t("heading label")), /* @__PURE__ */ React2.createElement(HeadingIcon, {
4121
4139
  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, {
4140
+ }))), /* @__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
4141
  value: "0"
4124
4142
  }, /* @__PURE__ */ React2.createElement(Paragraph, {
4125
4143
  className: iconStyles
@@ -4213,7 +4231,7 @@ var MarkdownLists = () => {
4213
4231
  const { t } = useTranslation(translationKey);
4214
4232
  return /* @__PURE__ */ React2.createElement(NaturalToolbar.ToggleGroup, {
4215
4233
  type: "single",
4216
- value: state?.listStyle ?? void 0
4234
+ value: state?.listStyle ? `list-${state.listStyle}` : ""
4217
4235
  }, markdownLists.map(({ type, getState, Icon }) => /* @__PURE__ */ React2.createElement(ToolbarButton, {
4218
4236
  key: type,
4219
4237
  value: type,
@@ -4233,7 +4251,7 @@ var markdownBlocks = [
4233
4251
  {
4234
4252
  type: "codeblock",
4235
4253
  Icon: CodeBlock,
4236
- getState: (state) => state.blockQuote,
4254
+ getState: (state) => state.blockType === "codeblock",
4237
4255
  disabled: (state) => !state.blankLine
4238
4256
  },
4239
4257
  {
@@ -4249,7 +4267,7 @@ var MarkdownBlocks = () => {
4249
4267
  const value = markdownBlocks.find(({ getState }) => state && getState(state));
4250
4268
  return /* @__PURE__ */ React2.createElement(NaturalToolbar.ToggleGroup, {
4251
4269
  type: "single",
4252
- value: value?.type
4270
+ value: value?.type ?? ""
4253
4271
  }, markdownBlocks.map(({ type, disabled, getState, Icon }) => /* @__PURE__ */ React2.createElement(ToolbarButton, {
4254
4272
  key: type,
4255
4273
  value: type,