@dxos/react-ui-editor 0.4.6-main.e47f68d → 0.4.6

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.
@@ -1900,18 +1900,6 @@ import { syntaxTree } from "@codemirror/language";
1900
1900
  import { RangeSetBuilder } from "@codemirror/state";
1901
1901
  import { EditorView as EditorView10, Decoration as Decoration4, WidgetType as WidgetType2, ViewPlugin as ViewPlugin3 } from "@codemirror/view";
1902
1902
  import { mx as mx2 } from "@dxos/react-ui-theme";
1903
- var FencedCodeBoundary = class extends WidgetType2 {
1904
- constructor(_className) {
1905
- super();
1906
- this._className = _className;
1907
- }
1908
- toDOM() {
1909
- const el = document.createElement("span");
1910
- el.innerHTML = " ";
1911
- el.className = mx2("cm-code cm-codeblock", this._className);
1912
- return el;
1913
- }
1914
- };
1915
1903
  var HorizontalRuleWidget = class extends WidgetType2 {
1916
1904
  toDOM() {
1917
1905
  const el = document.createElement("span");
@@ -1972,11 +1960,14 @@ var CheckboxWidget = class extends WidgetType2 {
1972
1960
  }
1973
1961
  };
1974
1962
  var hide = Decoration4.replace({});
1975
- var fencedCodeTop = Decoration4.replace({
1976
- widget: new FencedCodeBoundary("cm-codeblock-end cm-codeblock-first")
1963
+ var fencedCodeLine = Decoration4.line({
1964
+ class: mx2("cm-code cm-codeblock-line")
1965
+ });
1966
+ var fencedCodeLineFirst = Decoration4.line({
1967
+ class: mx2("cm-code cm-codeblock-line", "cm-codeblock-first")
1977
1968
  });
1978
- var fencedCodeBottom = Decoration4.replace({
1979
- widget: new FencedCodeBoundary("cm-codeblock-end cm-codeblock-last")
1969
+ var fencedCodeLineLast = Decoration4.line({
1970
+ class: mx2("cm-code cm-codeblock-line", "cm-codeblock-last")
1980
1971
  });
1981
1972
  var horizontalRule = Decoration4.replace({
1982
1973
  widget: new HorizontalRuleWidget()
@@ -2017,12 +2008,9 @@ var buildDecorations = (view, options) => {
2017
2008
  }
2018
2009
  const first = block.from <= node.from;
2019
2010
  const last = block.to >= node.to;
2011
+ builder.add(block.from, block.from, first ? fencedCodeLineFirst : last ? fencedCodeLineLast : fencedCodeLine);
2020
2012
  if (!editing && (first || last)) {
2021
- builder.add(block.from, block.to, first ? fencedCodeTop : fencedCodeBottom);
2022
- } else {
2023
- builder.add(block.from, block.from, Decoration4.line({
2024
- class: mx2("cm-code cm-codeblock-line", first && "cm-codeblock-first", last && "cm-codeblock-last")
2025
- }));
2013
+ builder.add(block.from, block.to, hide);
2026
2014
  }
2027
2015
  }
2028
2016
  return false;
@@ -2113,16 +2101,12 @@ var formattingStyles = EditorView10.baseTheme({
2113
2101
  }
2114
2102
  },
2115
2103
  "& .cm-codeblock-first": {
2116
- "&::after": {
2117
- borderTopLeftRadius: ".5rem",
2118
- borderTopRightRadius: ".5rem"
2119
- }
2104
+ borderTopLeftRadius: ".5rem",
2105
+ borderTopRightRadius: ".5rem"
2120
2106
  },
2121
2107
  "& .cm-codeblock-last": {
2122
- "&::after": {
2123
- borderBottomLeftRadius: ".5rem",
2124
- borderBottomRightRadius: ".5rem"
2125
- }
2108
+ borderBottomLeftRadius: ".5rem",
2109
+ borderBottomRightRadius: ".5rem"
2126
2110
  },
2127
2111
  "&light .cm-codeblock-line, &light .cm-activeLine.cm-codeblock-line": {
2128
2112
  background: getToken("extend.semanticColors.input.light"),
@@ -2132,18 +2116,6 @@ var formattingStyles = EditorView10.baseTheme({
2132
2116
  background: getToken("extend.semanticColors.input.dark"),
2133
2117
  mixBlendMode: "lighten"
2134
2118
  },
2135
- "&light .cm-codeblock-first, &light .cm-codeblock-last": {
2136
- mixBlendMode: "darken",
2137
- "&::after": {
2138
- background: getToken("extend.semanticColors.input.light")
2139
- }
2140
- },
2141
- "&dark .cm-codeblock-first, &dark .cm-codeblock-last": {
2142
- mixBlendMode: "lighten",
2143
- "&::after": {
2144
- background: getToken("extend.semanticColors.input.dark")
2145
- }
2146
- },
2147
2119
  "& .cm-hr": {
2148
2120
  display: "inline-block",
2149
2121
  width: "100%",
@@ -3281,6 +3253,14 @@ var image = (options = {}) => {
3281
3253
  provide: (field) => EditorView12.decorations.from(field)
3282
3254
  });
3283
3255
  };
3256
+ var preloaded = /* @__PURE__ */ new Set();
3257
+ var preloadImage = (url) => {
3258
+ if (!preloaded.has(url)) {
3259
+ const img = document.createElement("img");
3260
+ img.src = url;
3261
+ preloaded.add(url);
3262
+ }
3263
+ };
3284
3264
  var buildDecorations2 = (from, to, state) => {
3285
3265
  const decorations = [];
3286
3266
  const cursor = state.selection.main.head;
@@ -3291,6 +3271,7 @@ var buildDecorations2 = (from, to, state) => {
3291
3271
  if (urlNode) {
3292
3272
  const hide2 = state.readOnly || cursor < node.from || cursor > node.to;
3293
3273
  const url = state.sliceDoc(urlNode.from, urlNode.to);
3274
+ preloadImage(url);
3294
3275
  decorations.push(Decoration5.replace({
3295
3276
  block: true,
3296
3277
  widget: new ImageWidget(url)